BindingFlags.Public needed here as Exception.HResult is now public in .NET 4.5. This...
[mono.git] / mcs / class / System.Web / System.Web.Mail / MailMessage.cs
1 //
2 // System.Web.Mail.MailMessage.cs
3 //
4 // Author:
5 //    Lawrence Pit (loz@cable.a2000.nl)
6 //    Per Arneng (pt99par@student.bth.se)
7 //      Sanjay Gupta (gsanjay@novell.com)
8 //
9 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System.Collections;
32 using System.Collections.Specialized;
33 using System.Security.Permissions;
34 using System.Text;
35
36 namespace System.Web.Mail
37 {
38 #if !NET_4_0
39         // CAS
40         [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
41         [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
42 #endif
43         [Obsolete ("The recommended alternative is System.Net.Mail.MailMessage. http://go.microsoft.com/fwlink/?linkid=14202")]
44         public class MailMessage
45         {
46                 ArrayList attachments;
47                 string bcc;
48                 string body = String.Empty;
49                 Encoding bodyEncoding;
50                 MailFormat bodyFormat;
51                 string cc;              
52                 string from;
53                 ListDictionary headers;
54                 MailPriority priority;
55                 string subject = String.Empty;
56                 string to;
57                 string urlContentBase;
58                 string urlContentLocation;
59                 
60                 // Constructor          
61                 public MailMessage ()
62                 {
63                         attachments = new ArrayList (8);
64                         headers = new ListDictionary ();
65                         bodyEncoding = Encoding.Default;
66 #if NET_1_1
67                         fields = new Hashtable ();
68 #endif
69                 }               
70         
71                 // Properties
72                 public IList Attachments {
73                         get { return (IList) attachments; }
74                 }               
75                 
76                 public string Bcc {
77                         get { return bcc; } 
78                         set { bcc = value; }
79                 }
80         
81                 public string Body {
82                         get { return body; } 
83                         set { body = value; }
84                 }
85
86                 public Encoding BodyEncoding {
87                         get { return bodyEncoding; } 
88                         set { bodyEncoding = value; }
89                 }
90
91                 public MailFormat BodyFormat {
92                         get { return bodyFormat; } 
93                         set { bodyFormat = value; }
94                 }               
95
96                 public string Cc {
97                         get { return cc; } 
98                         set { cc = value; }
99                 }
100
101                 public string From {
102                         get { return from; } 
103                         set { from = value; }
104                 }
105
106                 public IDictionary Headers {
107                         get { return (IDictionary) headers; }
108                 }
109                 
110                 public MailPriority Priority {
111                         get { return priority; } 
112                         set { priority = value; }
113                 }
114                 
115                 public string Subject {
116                         get { return subject; } 
117                         set { subject = value; }
118                 }
119
120                 public string To {
121                         get { return to; }   
122                         set { to = value; }
123                 }
124
125                 public string UrlContentBase {
126                         get { return urlContentBase; } 
127                         set { urlContentBase = value; }
128                 }
129
130                 public string UrlContentLocation {
131                         get { return urlContentLocation; } 
132                         set { urlContentLocation = value; }
133                 }
134
135 #if NET_1_1
136                 Hashtable fields;
137                 
138                 public IDictionary Fields {
139                         get {
140                                 return (IDictionary) fields;
141                         }
142                 }
143 #endif
144         }
145 }