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