final MimeBodyPart mimeText = new PreencodedMimeBodyPart("base64"); mimeText.setDataHandler(new DataHandler(new ByteArrayDataSource( Base64.encodeBase64(messageText.getBytes("UTF-8")), contentType + "; charset=\"utf-8\"")));
private MimeBodyPart addAttachment(final String fileName, final String fileContent) throws MessagingException { if (fileName == null || fileContent == null) { return null; } LOG.debug("addAttachment()"); MimeBodyPart filePart = new PreencodedMimeBodyPart("base64"); filePart.setText(fileContent); LOG.debug("addAttachment success !"); return filePart; }
while ( it.hasNext() ) { Entry<String, String> pairs = it.next(); PreencodedMimeBodyPart pmp = new PreencodedMimeBodyPart( "base64" ); pmp.setHeader( "Content-ID", "<" + pairs.getKey() + ">" ); pmp.setDisposition( MimeBodyPart.INLINE );
final MimeBodyPart mimeText = new PreencodedMimeBodyPart("base64"); mimeText.setDataHandler(new DataHandler(new ByteArrayDataSource( Base64.encodeBase64(messageText.getBytes("UTF-8")), contentType + "; charset=\"utf-8\"")));