Added RedirectUsingNamedRoute
[castle.git] / Components / EmailSender / Castle.Components.Common.EmailSender / Message.cs
blobc654e8aaddece0659d2cbd60b7d1d8b65c741f9d
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Components.Common.EmailSender
17 using System;
18 using System.Collections.Generic;
19 using System.Net;
20 using System.Net.Mail;
21 using System.Text;
22 using System.Collections;
23 using System.Collections.Specialized;
25 /// <summary>
26 /// Message formats
27 /// </summary>
28 public enum Format
30 /// <summary>
31 /// The body is composed of html content
32 /// </summary>
33 Html,
34 /// <summary>
35 /// The body is pure text
36 /// </summary>
37 Text
40 /// <summary>
41 /// Message priority
42 /// </summary>
43 public enum MessagePriority
45 Normal,
46 High,
47 Low
50 /// <summary>
51 /// Abstracts an e-mail message
52 /// </summary>
53 public class Message
55 private String to;
56 private String from;
57 private String cc;
58 private String bcc;
59 private String body;
60 private String subject;
61 private Format format = Format.Text;
62 private Encoding encoding = Encoding.ASCII;
63 private IDictionary headers = new HybridDictionary();
64 private IDictionary fields = new HybridDictionary();
65 private MessagePriority priority = MessagePriority.Normal;
66 private MessageAttachmentCollection attachments = new MessageAttachmentCollection();
67 private readonly IDictionary<string, LinkedResource> linkedResources = new Dictionary<string, LinkedResource>();
69 /// <summary>
70 /// Initializes a new instance of the <see cref="Message"/> class.
71 /// </summary>
72 public Message()
76 /// <summary>
77 /// Initializes a new instance of the <see cref="Message"/> class.
78 /// </summary>
79 /// <param name="from">From header.</param>
80 /// <param name="to">To header.</param>
81 /// <param name="subject">The subject header.</param>
82 /// <param name="body">The message body.</param>
83 public Message(string from, string to, string subject, string body)
85 this.to = to;
86 this.from = from;
87 this.body = body;
88 this.subject = subject;
91 public String To
93 get { return to; }
94 set { to = value; }
97 public String From
99 get { return from; }
100 set { from = value; }
103 public String Cc
105 get { return cc; }
106 set { cc = value; }
109 public String Bcc
111 get { return bcc; }
112 set { bcc = value; }
115 public String Body
117 get { return body; }
118 set { body = value; }
121 public String Subject
123 get { return subject; }
124 set { subject = value; }
127 public Format Format
129 get { return format; }
130 set { format = value; }
133 public Encoding Encoding
135 get { return encoding; }
136 set { encoding = value; }
139 public MessagePriority Priority
141 get { return priority; }
142 set { priority = value; }
145 public IDictionary Headers
147 get { return headers; }
150 public IDictionary Fields
152 get { return fields; }
155 public MessageAttachmentCollection Attachments
157 get { return attachments; }
160 public IDictionary<string, LinkedResource> Resources
162 get { return linkedResources; }