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