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