MailMessage.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. AttachmentCollection alternateViews;
  39. AttachmentCollection attachments;
  40. MailAddressCollection bcc;
  41. string body;
  42. ContentType bodyContentType;
  43. Encoding bodyEncoding;
  44. MailAddressCollection cc;
  45. MailAddress from;
  46. NameValueCollection headers;
  47. MailAddressCollection to;
  48. string subject;
  49. Encoding subjectEncoding;
  50. #endregion // Fields
  51. #region Constructors
  52. public MailMessage (MailAddress from, MailAddress to)
  53. {
  54. From = from;
  55. this.to = new MailAddressCollection ();
  56. this.to.Add (to);
  57. alternateViews = new AttachmentCollection ();
  58. attachments = new AttachmentCollection ();
  59. bcc = new MailAddressCollection ();
  60. cc = new MailAddressCollection ();
  61. bodyContentType = new ContentType (MediaTypeNames.Application.Octet);
  62. headers = new NameValueCollection ();
  63. headers.Add ("MIME-Version", "1.0");
  64. }
  65. public MailMessage (string from, string to)
  66. : this (new MailAddress (from), new MailAddress (to))
  67. {
  68. }
  69. public MailMessage (string from, string to, string subject, string body)
  70. : this (new MailAddress (from), new MailAddress (to))
  71. {
  72. Body = body;
  73. Subject = subject;
  74. }
  75. #endregion // Constructors
  76. #region Properties
  77. [CLSCompliant (false)]
  78. public AttachmentCollection AlternateViews {
  79. get { return alternateViews; }
  80. }
  81. [CLSCompliant (false)]
  82. public AttachmentCollection Attachments {
  83. get { return attachments; }
  84. }
  85. [CLSCompliant (false)]
  86. public MailAddressCollection Bcc {
  87. get { return bcc; }
  88. }
  89. public string Body {
  90. get { return body; }
  91. set { body = value; }
  92. }
  93. public ContentType BodyContentType {
  94. get { return bodyContentType; }
  95. }
  96. public Encoding BodyEncoding {
  97. get { return bodyEncoding; }
  98. set {
  99. bodyEncoding = value;
  100. bodyContentType.CharSet = value.WebName;
  101. }
  102. }
  103. [CLSCompliant (false)]
  104. public MailAddressCollection CC {
  105. get { return cc; }
  106. }
  107. public MailAddress From {
  108. get { return from; }
  109. set { from = value; }
  110. }
  111. public NameValueCollection Headers {
  112. get { return headers; }
  113. }
  114. public string Subject {
  115. get { return subject; }
  116. set { subject = value; }
  117. }
  118. public Encoding SubjectEncoding {
  119. get { return subjectEncoding; }
  120. set { subjectEncoding = value; }
  121. }
  122. [CLSCompliant (false)]
  123. public MailAddressCollection To {
  124. get { return to; }
  125. }
  126. #endregion // Properties
  127. #region Methods
  128. [MonoTODO]
  129. public void Dispose ()
  130. {
  131. }
  132. [MonoTODO]
  133. ~MailMessage ()
  134. {
  135. }
  136. #endregion // Methods
  137. }
  138. }
  139. #endif // NET_2_0