MailAttachment.cs 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // System.Web.Mail.MailAttachment.cs
  3. //
  4. // Author:
  5. // Lawrence Pit ([email protected])
  6. // Per Arneng ([email protected])
  7. //
  8. namespace System.Web.Mail
  9. {
  10. public class MailAttachment
  11. {
  12. private string filename;
  13. private MailEncoding encoding;
  14. public MailAttachment (string filename) :
  15. this (filename, MailEncoding.Base64)
  16. {
  17. }
  18. public MailAttachment (string filename, MailEncoding encoding)
  19. {
  20. this.filename = filename;
  21. this.encoding = encoding;
  22. try {
  23. System.IO.File.OpenRead (filename).Close ();
  24. } catch (Exception) {
  25. throw new System.Web.HttpException ("Cannot find file: '" +
  26. filename + "'." );
  27. }
  28. }
  29. // Properties
  30. public string Filename
  31. {
  32. get { return filename; }
  33. }
  34. public MailEncoding Encoding
  35. {
  36. get { return encoding; }
  37. }
  38. }
  39. } //namespace System.Web.Mail