Multipart composeMessageBody(ItemOrder order) throws MessagingException { String html = htmlCreator.generateHtmlImage(order.getItemResponse().getImgBaseSrc()); BodyPart mediaPart = new MimeBodyPart(); mediaPart.setContent(html, "text/html"); BodyPart textPart = new MimeBodyPart(); textPart.setContent(order.dump(), "text/plain; charset=UTF-8"); Multipart messageBody = new MimeMultipart(); messageBody.addBodyPart(textPart); messageBody.addBodyPart(mediaPart); return messageBody; }
protected void setMessageAddresses(MimeMessage mail, ItemOrder order) throws AddressException, MessagingException { InternetAddress destination = InternetAddress.parse(destinationAddress)[0]; mail.setFrom(destination); mail.setReplyTo(InternetAddress.parse(order.getCustomerEmail())); mail.setRecipient(RecipientType.TO, destination); }
protected void setMessageSubject(MimeMessage mail, ItemOrder order) throws MessagingException { String subject = context.getMessage( SUBJECT_MESSAGE_KEY, new Object[] {order.getItemResponse().getId()}, Locale.getDefault()); mail.setSubject(subject, "UTF-8"); }
protected void setMessageContent(MimeMessage mail, ItemOrder order) throws MessagingException { Multipart messageBody = composeMessageBody(order); mail.setContent(messageBody); log.info(String.format("Order %s", order.dump())); }