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