MailMessage.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. //
  2. // System.Net.Mail.MailMessage.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2004
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System.Collections.Specialized;
  31. using System.Net.Mime;
  32. using System.Text;
  33. namespace System.Net.Mail {
  34. [MonoTODO]
  35. public class MailMessage : IDisposable
  36. {
  37. #region Fields
  38. AlternateViewCollection alternateViews;
  39. AttachmentCollection attachments;
  40. MailAddressCollection bcc;
  41. string body;
  42. bool isBodyHtml;
  43. MailPriority priority;
  44. MailAddress replyTo, sender;
  45. DeliveryNotificationOptions deliveryNotificationOptions;
  46. Encoding bodyEncoding;
  47. MailAddressCollection cc;
  48. MailAddress from;
  49. NameValueCollection headers;
  50. MailAddressCollection to;
  51. string subject;
  52. Encoding subjectEncoding;
  53. #endregion // Fields
  54. #region Constructors
  55. public MailMessage ()
  56. {
  57. }
  58. public MailMessage (MailAddress from, MailAddress to)
  59. {
  60. From = from;
  61. this.to = new MailAddressCollection ();
  62. this.to.Add (to);
  63. alternateViews = new AlternateViewCollection ();
  64. attachments = new AttachmentCollection ();
  65. bcc = new MailAddressCollection ();
  66. cc = new MailAddressCollection ();
  67. headers = new NameValueCollection ();
  68. headers.Add ("MIME-Version", "1.0");
  69. }
  70. public MailMessage (string from, string to)
  71. : this (new MailAddress (from), new MailAddress (to))
  72. {
  73. }
  74. public MailMessage (string from, string to, string subject, string body)
  75. : this (new MailAddress (from), new MailAddress (to))
  76. {
  77. Body = body;
  78. Subject = subject;
  79. }
  80. #endregion // Constructors
  81. #region Properties
  82. public AlternateViewCollection AlternateViews {
  83. get { return alternateViews; }
  84. }
  85. public AttachmentCollection Attachments {
  86. get { return attachments; }
  87. }
  88. public MailAddressCollection Bcc {
  89. get { return bcc; }
  90. }
  91. public string Body {
  92. get { return body; }
  93. set { body = value; }
  94. }
  95. public Encoding BodyEncoding {
  96. get { return bodyEncoding; }
  97. set {
  98. bodyEncoding = value;
  99. //bodyContentType.CharSet = value.WebName;
  100. }
  101. }
  102. public MailAddressCollection CC {
  103. get { return cc; }
  104. }
  105. public DeliveryNotificationOptions DeliveryNotificationOptions {
  106. get { return deliveryNotificationOptions; }
  107. set { deliveryNotificationOptions = value; }
  108. }
  109. public MailAddress From {
  110. get { return from; }
  111. set { from = value; }
  112. }
  113. public NameValueCollection Headers {
  114. get { return headers; }
  115. }
  116. public bool IsBodyHtml {
  117. get { return isBodyHtml; }
  118. set { isBodyHtml = value; }
  119. }
  120. public MailPriority Priority {
  121. get { return priority; }
  122. set { priority = value; }
  123. }
  124. public MailAddress ReplyTo {
  125. get { return replyTo; }
  126. set { replyTo = value; }
  127. }
  128. public MailAddress Sender {
  129. get { return sender; }
  130. set { sender = value; }
  131. }
  132. public string Subject {
  133. get { return subject; }
  134. set { subject = value; }
  135. }
  136. public Encoding SubjectEncoding {
  137. get { return subjectEncoding; }
  138. set { subjectEncoding = value; }
  139. }
  140. public MailAddressCollection To {
  141. get { return to; }
  142. }
  143. #endregion // Properties
  144. #region Methods
  145. public void Dispose ()
  146. {
  147. Dispose (true);
  148. GC.SuppressFinalize (this);
  149. }
  150. protected virtual void Dispose (bool disposing)
  151. {
  152. }
  153. #endregion // Methods
  154. }
  155. }
  156. #endif // NET_2_0