MailMessageWrapper.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // System.Web.Mail.MailMessageWrapper.cs
  3. //
  4. // Author(s):
  5. // Per Arneng <[email protected]>
  6. //
  7. //
  8. using System;
  9. using System.Collections;
  10. using System.Text;
  11. namespace System.Web.Mail {
  12. // wraps a MailMessage to make an easier
  13. // interface to work with collections of
  14. // addresses instead of a single string
  15. internal class MailMessageWrapper {
  16. private MailAddressCollection bcc = new MailAddressCollection();
  17. private MailAddressCollection cc = new MailAddressCollection();
  18. private MailAddress from;
  19. private MailAddressCollection to = new MailAddressCollection();
  20. private MailMessage message;
  21. // Constructor
  22. public MailMessageWrapper( MailMessage message )
  23. {
  24. this.message = message;
  25. if(message.From != null ) from = MailAddress.Parse( message.From );
  26. if(message.To != null ) to = MailAddressCollection.Parse( message.To );
  27. if(message.Cc != null )cc = MailAddressCollection.Parse( message.Cc );
  28. if(message.Bcc != null )bcc = MailAddressCollection.Parse( message.Bcc );
  29. }
  30. // Properties
  31. public IList Attachments {
  32. get { return message.Attachments; }
  33. }
  34. public MailAddressCollection Bcc {
  35. get { return bcc; }
  36. }
  37. public string Body {
  38. get { return message.Body; }
  39. set { message.Body = value; }
  40. }
  41. public Encoding BodyEncoding {
  42. get { return message.BodyEncoding; }
  43. set { message.BodyEncoding = value; }
  44. }
  45. public MailFormat BodyFormat {
  46. get { return message.BodyFormat; }
  47. set { message.BodyFormat = value; }
  48. }
  49. public MailAddressCollection Cc {
  50. get { return cc; }
  51. }
  52. public MailAddress From {
  53. get { return from; }
  54. }
  55. public IDictionary Headers {
  56. get { return message.Headers; }
  57. }
  58. public MailPriority Priority {
  59. get { return message.Priority; }
  60. set { message.Priority = value; }
  61. }
  62. public string Subject {
  63. get { return message.Subject; }
  64. set { message.Subject = value; }
  65. }
  66. public MailAddressCollection To {
  67. get { return to; }
  68. }
  69. public string UrlContentBase {
  70. get { return message.UrlContentBase; }
  71. }
  72. public string UrlContentLocation {
  73. get { return message.UrlContentLocation; }
  74. }
  75. }
  76. }