|
|
@ -218,7 +218,7 @@ public class MailUtil {
|
|
|
|
* @param attachmentByte
|
|
|
|
* @param attachmentByte
|
|
|
|
* @throws MessagingException
|
|
|
|
* @throws MessagingException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void addAttachment(String fileName, byte[] attachmentByte) throws MessagingException {
|
|
|
|
public void addAttachment(String fileName, byte[] attachmentByte) throws MessagingException, UnsupportedEncodingException {
|
|
|
|
addAttachment(fileName, attachmentByte,
|
|
|
|
addAttachment(fileName, attachmentByte,
|
|
|
|
FileContentTypeTool.getContentType(StringTool.getStringFileSuffix(fileName, true)));
|
|
|
|
FileContentTypeTool.getContentType(StringTool.getStringFileSuffix(fileName, true)));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -231,11 +231,12 @@ public class MailUtil {
|
|
|
|
* @param contentType
|
|
|
|
* @param contentType
|
|
|
|
* @throws MessagingException
|
|
|
|
* @throws MessagingException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void addAttachment(String fileName, byte[] attachmentByte, String contentType) throws MessagingException {
|
|
|
|
public void addAttachment(String fileName, byte[] attachmentByte, String contentType) throws MessagingException, UnsupportedEncodingException {
|
|
|
|
BodyPart attachmentBodyPart = new MimeBodyPart();
|
|
|
|
BodyPart attachmentBodyPart = new MimeBodyPart();
|
|
|
|
DataSource source = new ByteArrayDataSource(attachmentByte, contentType);
|
|
|
|
DataSource source = new ByteArrayDataSource(attachmentByte, contentType);
|
|
|
|
attachmentBodyPart.setDataHandler(new DataHandler(source));
|
|
|
|
attachmentBodyPart.setDataHandler(new DataHandler(source));
|
|
|
|
attachmentBodyPart.setFileName(fileName);
|
|
|
|
String name = MimeUtility.encodeText(fileName);
|
|
|
|
|
|
|
|
attachmentBodyPart.setFileName(name);
|
|
|
|
attachmentList.add(attachmentBodyPart);
|
|
|
|
attachmentList.add(attachmentBodyPart);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|