001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.kernel.mail;
022:
023: import java.io.File;
024: import java.io.Serializable;
025:
026: import java.util.ArrayList;
027: import java.util.List;
028:
029: import javax.mail.internet.InternetAddress;
030:
031: /**
032: * <a href="MailMessage.java.html"><b><i>View Source</i></b></a>
033: *
034: * @author Brian Wing Shun Chan
035: * @author Neil Griffin
036: *
037: */
038: public class MailMessage implements Serializable {
039:
040: public MailMessage(InternetAddress from, InternetAddress to,
041: String subject, String body) {
042:
043: this (from, to, subject, body, false);
044: }
045:
046: public MailMessage(InternetAddress from, InternetAddress to,
047: String subject, String body, boolean htmlFormat) {
048:
049: this (from, new InternetAddress[] { to }, null, null, subject,
050: body, htmlFormat);
051: }
052:
053: public MailMessage(InternetAddress from, InternetAddress[] to,
054: InternetAddress[] cc, InternetAddress[] bcc,
055: String subject, String body) {
056:
057: this (from, to, cc, bcc, subject, body, false);
058: }
059:
060: public MailMessage(InternetAddress from, InternetAddress[] to,
061: InternetAddress[] cc, InternetAddress[] bcc,
062: String subject, String body, boolean htmlFormat) {
063:
064: _from = from;
065: _to = to;
066: _cc = cc;
067: _bcc = bcc;
068: _subject = subject;
069: _body = body;
070: _htmlFormat = htmlFormat;
071: _attachments = new ArrayList();
072: }
073:
074: public InternetAddress getFrom() {
075: return _from;
076: }
077:
078: public void setFrom(InternetAddress from) {
079: _from = from;
080: }
081:
082: public InternetAddress[] getTo() {
083: return _to;
084: }
085:
086: public void setTo(InternetAddress[] to) {
087: _to = to;
088: }
089:
090: public InternetAddress[] getCC() {
091: return _cc;
092: }
093:
094: public void setCC(InternetAddress[] cc) {
095: _cc = cc;
096: }
097:
098: public InternetAddress[] getBCC() {
099: return _bcc;
100: }
101:
102: public void setBCC(InternetAddress[] bcc) {
103: _bcc = bcc;
104: }
105:
106: public String getSubject() {
107: return _subject;
108: }
109:
110: public void setSubject(String subject) {
111: _subject = subject;
112: }
113:
114: public String getBody() {
115: return _body;
116: }
117:
118: public void setBody(String body) {
119: _body = body;
120: }
121:
122: public boolean getHTMLFormat() {
123: return _htmlFormat;
124: }
125:
126: public boolean isHTMLFormat() {
127: return _htmlFormat;
128: }
129:
130: public void setHTMLFormat(boolean htmlFormat) {
131: _htmlFormat = htmlFormat;
132: }
133:
134: public InternetAddress[] getReplyTo() {
135: return _replyTo;
136: }
137:
138: public void setReplyTo(InternetAddress[] replyTo) {
139: _replyTo = replyTo;
140: }
141:
142: public String getMessageId() {
143: return _messageId;
144: }
145:
146: public void setMessageId(String messageId) {
147: _messageId = messageId;
148: }
149:
150: public String getInReplyTo() {
151: return _inReplyTo;
152: }
153:
154: public void setInReplyTo(String inReplyTo) {
155: _inReplyTo = inReplyTo;
156: }
157:
158: public void addAttachment(File attachment) {
159: if (attachment != null) {
160: _attachments.add(attachment);
161: }
162: }
163:
164: public File[] getAttachments() {
165: return (File[]) _attachments.toArray(new File[0]);
166: }
167:
168: private InternetAddress _from;
169: private InternetAddress[] _to;
170: private InternetAddress[] _cc;
171: private InternetAddress[] _bcc;
172: private String _subject;
173: private String _body;
174: private boolean _htmlFormat;
175: private InternetAddress[] _replyTo;
176: private String _messageId;
177: private String _inReplyTo;
178: private List _attachments;
179:
180: }
|