MailAttachment.cs 852 B

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