1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.mail.javamail;
18
19 import java.util.Date;
20 import javax.mail.MessagingException;
21 import javax.mail.internet.MimeMessage;
22
23 import org.springframework.mail.MailMessage;
24 import org.springframework.mail.MailParseException;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 public class MimeMailMessage implements MailMessage {
40
41 private final MimeMessageHelper helper;
42
43
44
45
46
47
48 public MimeMailMessage(MimeMessageHelper mimeMessageHelper) {
49 this.helper = mimeMessageHelper;
50 }
51
52
53
54
55
56 public MimeMailMessage(MimeMessage mimeMessage) {
57 this.helper = new MimeMessageHelper(mimeMessage);
58 }
59
60
61
62
63 public final MimeMessageHelper getMimeMessageHelper() {
64 return this.helper;
65 }
66
67
68
69
70 public final MimeMessage getMimeMessage() {
71 return this.helper.getMimeMessage();
72 }
73
74
75 @Override
76 public void setFrom(String from) throws MailParseException {
77 try {
78 this.helper.setFrom(from);
79 }
80 catch (MessagingException ex) {
81 throw new MailParseException(ex);
82 }
83 }
84
85 @Override
86 public void setReplyTo(String replyTo) throws MailParseException {
87 try {
88 this.helper.setReplyTo(replyTo);
89 }
90 catch (MessagingException ex) {
91 throw new MailParseException(ex);
92 }
93 }
94
95 @Override
96 public void setTo(String to) throws MailParseException {
97 try {
98 this.helper.setTo(to);
99 }
100 catch (MessagingException ex) {
101 throw new MailParseException(ex);
102 }
103 }
104
105 @Override
106 public void setTo(String[] to) throws MailParseException {
107 try {
108 this.helper.setTo(to);
109 }
110 catch (MessagingException ex) {
111 throw new MailParseException(ex);
112 }
113 }
114
115 @Override
116 public void setCc(String cc) throws MailParseException {
117 try {
118 this.helper.setCc(cc);
119 }
120 catch (MessagingException ex) {
121 throw new MailParseException(ex);
122 }
123 }
124
125 @Override
126 public void setCc(String[] cc) throws MailParseException {
127 try {
128 this.helper.setCc(cc);
129 }
130 catch (MessagingException ex) {
131 throw new MailParseException(ex);
132 }
133 }
134
135 @Override
136 public void setBcc(String bcc) throws MailParseException {
137 try {
138 this.helper.setBcc(bcc);
139 }
140 catch (MessagingException ex) {
141 throw new MailParseException(ex);
142 }
143 }
144
145 @Override
146 public void setBcc(String[] bcc) throws MailParseException {
147 try {
148 this.helper.setBcc(bcc);
149 }
150 catch (MessagingException ex) {
151 throw new MailParseException(ex);
152 }
153 }
154
155 @Override
156 public void setSentDate(Date sentDate) throws MailParseException {
157 try {
158 this.helper.setSentDate(sentDate);
159 }
160 catch (MessagingException ex) {
161 throw new MailParseException(ex);
162 }
163 }
164
165 @Override
166 public void setSubject(String subject) throws MailParseException {
167 try {
168 this.helper.setSubject(subject);
169 }
170 catch (MessagingException ex) {
171 throw new MailParseException(ex);
172 }
173 }
174
175 @Override
176 public void setText(String text) throws MailParseException {
177 try {
178 this.helper.setText(text);
179 }
180 catch (MessagingException ex) {
181 throw new MailParseException(ex);
182 }
183 }
184
185 }