1   /**
2    * Copyright (c) 2000-2007 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   *
39   */
40  public class MailMessage implements Serializable {
41  
42      public MailMessage(InternetAddress from, InternetAddress to,
43                         String subject, String body) {
44  
45          this(from, to, subject, body, false);
46      }
47  
48      public MailMessage(InternetAddress from, InternetAddress to,
49                         String subject, String body, boolean htmlFormat) {
50  
51          this(from, new InternetAddress[] {to}, null, null, subject, body,
52               htmlFormat);
53      }
54  
55      public MailMessage(InternetAddress from, InternetAddress[] to,
56                         InternetAddress[] cc, InternetAddress[] bcc,
57                         String subject, String body) {
58  
59          this(from, to, cc, bcc, subject, body, false);
60      }
61  
62      public MailMessage(InternetAddress from, InternetAddress[] to,
63                         InternetAddress[] cc, InternetAddress[] bcc,
64                         String subject, String body, boolean htmlFormat) {
65  
66          _from = from;
67          _to = to;
68          _cc = cc;
69          _bcc = bcc;
70          _subject = subject;
71          _body = body;
72          _htmlFormat = htmlFormat;
73          _attachments = new ArrayList();
74      }
75  
76      public InternetAddress getFrom() {
77          return _from;
78      }
79  
80      public void setFrom(InternetAddress from) {
81          _from = from;
82      }
83  
84      public InternetAddress[] getTo() {
85          return _to;
86      }
87  
88      public void setTo(InternetAddress[] to) {
89          _to = to;
90      }
91  
92      public InternetAddress[] getCC() {
93          return _cc;
94      }
95  
96      public void setCC(InternetAddress[] cc) {
97          _cc = cc;
98      }
99  
100     public InternetAddress[] getBCC() {
101         return _bcc;
102     }
103 
104     public void setBCC(InternetAddress[] bcc) {
105         _bcc = bcc;
106     }
107 
108     public String getSubject() {
109         return _subject;
110     }
111 
112     public void setSubject(String subject) {
113         _subject = subject;
114     }
115 
116     public String getBody() {
117         return _body;
118     }
119 
120     public void setBody(String body) {
121         _body = body;
122     }
123 
124     public boolean getHTMLFormat() {
125         return _htmlFormat;
126     }
127 
128     public boolean isHTMLFormat() {
129         return _htmlFormat;
130     }
131 
132     public void setHTMLFormat(boolean htmlFormat) {
133         _htmlFormat = htmlFormat;
134     }
135 
136     public InternetAddress[] getReplyTo() {
137         return _replyTo;
138     }
139 
140     public void setReplyTo(InternetAddress[] replyTo) {
141         _replyTo = replyTo;
142     }
143 
144     public String getMessageId() {
145         return _messageId;
146     }
147 
148     public void setMessageId(String messageId) {
149         _messageId = messageId;
150     }
151 
152     public String getInReplyTo() {
153         return _inReplyTo;
154     }
155 
156     public void setInReplyTo(String inReplyTo) {
157         _inReplyTo = inReplyTo;
158     }
159 
160     public void addAttachment(File attachment) {
161         if (attachment != null) {
162             _attachments.add(attachment);
163         }
164     }
165 
166     public File[] getAttachments() {
167         return (File[])_attachments.toArray(new File[0]);
168     }
169 
170     private InternetAddress _from;
171     private InternetAddress[] _to;
172     private InternetAddress[] _cc;
173     private InternetAddress[] _bcc;
174     private String _subject;
175     private String _body;
176     private boolean _htmlFormat;
177     private InternetAddress[] _replyTo;
178     private String _messageId;
179     private String _inReplyTo;
180     private List _attachments;
181 
182 }