1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.kernel.mail;
21  
22  import java.io.File;
23  import java.io.Serializable;
24  
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  import javax.mail.internet.InternetAddress;
29  
30  /**
31   * <a href="MailMessage.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Brian Wing Shun Chan
34   * @author Neil Griffin
35   * @author Raymond Augé
36   * @author Thiago Moreira
37   *
38   */
39  public class MailMessage implements Serializable {
40  
41      public MailMessage() {
42      }
43  
44      public MailMessage(
45          InternetAddress from, InternetAddress to, String subject, String body,
46          boolean htmlFormat) {
47  
48          _from = from;
49          _to = new InternetAddress[] {to};
50          _subject = subject;
51          _body = body;
52          _htmlFormat = htmlFormat;
53      }
54  
55      public void addAttachment(File attachment) {
56          if (attachment != null) {
57              _attachments.add(attachment);
58          }
59      }
60  
61      public File[] getAttachments() {
62          return _attachments.toArray(new File[_attachments.size()]);
63      }
64  
65      public InternetAddress[] getBCC() {
66          return _bcc;
67      }
68  
69      public String getBody() {
70          return _body;
71      }
72  
73      public InternetAddress[] getBulkAddresses() {
74          return _bulkAddresses;
75      }
76  
77      public InternetAddress[] getCC() {
78          return _cc;
79      }
80  
81      public InternetAddress getFrom() {
82          return _from;
83      }
84  
85      public boolean getHTMLFormat() {
86          return _htmlFormat;
87      }
88  
89      public String getInReplyTo() {
90          return _inReplyTo;
91      }
92  
93      public String getMessageId() {
94          return _messageId;
95      }
96  
97      public InternetAddress[] getReplyTo() {
98          return _replyTo;
99      }
100 
101     public SMTPAccount getSMTPAccount() {
102         return _smtpAccount;
103     }
104 
105     public String getSubject() {
106         return _subject;
107     }
108 
109     public InternetAddress[] getTo() {
110         return _to;
111     }
112 
113     public boolean isHTMLFormat() {
114         return _htmlFormat;
115     }
116 
117     public void setBCC(InternetAddress[] bcc) {
118         _bcc = bcc;
119     }
120 
121     public void setBody(String body) {
122         _body = body;
123     }
124 
125     public void setBulkAddresses(InternetAddress[] bulkAddresses) {
126         _bulkAddresses = bulkAddresses;
127     }
128 
129     public void setCC(InternetAddress[] cc) {
130         _cc = cc;
131     }
132 
133     public void setFrom(InternetAddress from) {
134         _from = from;
135     }
136 
137     public void setHTMLFormat(boolean htmlFormat) {
138         _htmlFormat = htmlFormat;
139     }
140 
141     public void setInReplyTo(String inReplyTo) {
142         _inReplyTo = inReplyTo;
143     }
144 
145     public void setMessageId(String messageId) {
146         _messageId = messageId;
147     }
148 
149     public void setReplyTo(InternetAddress[] replyTo) {
150         _replyTo = replyTo;
151     }
152 
153     public void setSMTPAccount(SMTPAccount account) {
154         _smtpAccount = account;
155     }
156 
157     public void setSubject(String subject) {
158         _subject = subject;
159     }
160 
161     public void setTo(InternetAddress[] to) {
162         _to = to;
163     }
164 
165     private InternetAddress _from;
166     private InternetAddress[] _to;
167     private InternetAddress[] _cc;
168     private InternetAddress[] _bcc;
169     private InternetAddress[] _bulkAddresses;
170     private String _subject;
171     private String _body;
172     private boolean _htmlFormat;
173     private InternetAddress[] _replyTo;
174     private String _messageId;
175     private String _inReplyTo;
176     private List<File> _attachments = new ArrayList<File>();
177     private SMTPAccount _smtpAccount;
178 
179 }