/** * Sets the message text and adds attachments. * @param text * @param attachments Can be <code>null</code> * @throws MessagingException */ public void setContent(String text, List<Attachment> attachments) throws MessagingException { if (attachments==null || attachments.isEmpty()) setText(text, "UTF-8"); else { Multipart multiPart = new MimeMultipart(); MimeBodyPart textPart = new MimeBodyPart(); textPart.setText(text, "UTF-8"); multiPart.addBodyPart(textPart); attach(multiPart, attachments); setContent(multiPart); } }