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