@Test public void testCreateMessage() throws MessagingException, IOException { MimeMessage msg = sut.createMessage(); Assert.notNull(msg, "Message should not be null."); Assert.isInstanceOf(Multipart.class, msg.getContent(), "Content should be multipart."); Assert.notNull(msg.getSentDate(), "Date should be specified."); Address[] list = msg.getFrom(); assertEquals(1, list.length); assertEquals(DEFAULT_FROM, list[0].toString()); }
public MimeMessage createMessage() throws MessagingException { Properties mailProps = new Properties(); mailProps.put("mail.transport.protocol", mailTransportProtocol); for (Map.Entry<String, String> cfg : transportConfiguration.entrySet()) { mailProps.put(cfg.getKey(), cfg.getValue()); } Session mailSession = Session.getInstance(mailProps, null); MimeMessage msg = new MimeMessage(mailSession); msg.setSentDate(new Date()); msg.setFrom(new InternetAddress(defaultFromAddress)); msg.setContent(new MimeMultipart("alternative")); return msg; }
EmailerFactory { public MimeMessage createMessage() throws MessagingException { Properties mailProps = new Properties(); mailProps.put("mail.transport.protocol", mailTransportProtocol); for (Map.Entry<String, String> cfg : transportConfiguration.entrySet()) { mailProps.put(cfg.getKey(), cfg.getValue()); } Session mailSession = Session.getInstance(mailProps, null); MimeMessage msg = new MimeMessage(mailSession); msg.setSentDate(new Date()); msg.setFrom(new InternetAddress(defaultFromAddress)); msg.setContent(new MimeMultipart("alternative")); return msg; } }
EmailerFactory { public MimeMessage createMessage() throws MessagingException { Properties mailProps = new Properties(); mailProps.put("mail.transport.protocol", mailTransportProtocol); for (Map.Entry<String, String> cfg : transportConfiguration.entrySet()) { mailProps.put(cfg.getKey(), cfg.getValue()); } Session mailSession = Session.getInstance(mailProps, null); MimeMessage msg = new MimeMessage(mailSession); msg.setSentDate(new Date()); msg.setFrom(new InternetAddress(defaultFromAddress)); msg.setContent(new MimeMultipart("alternative")); return msg; } EmailerFactory(final String inMailTransportProtocol, final Map<String, String> inTransportConfiguration,
            final String inDefaultFromAddress); }
EmailerFactory { public MimeMessage createMessage() throws MessagingException { Properties mailProps = new Properties(); mailProps.put("mail.transport.protocol", mailTransportProtocol); for (Map.Entry<String, String> cfg : transportConfiguration.entrySet()) { mailProps.put(cfg.getKey(), cfg.getValue()); } Session mailSession = Session.getInstance(mailProps, null); MimeMessage msg = new MimeMessage(mailSession); msg.setSentDate(new Date()); msg.setFrom(new InternetAddress(defaultFromAddress)); msg.setContent(new MimeMultipart("alternative")); return msg; } EmailerFactory(final String inMailTransportProtocol, final Map<String, String> inTransportConfiguration,
            final String inDefaultFromAddress); static String buildEmailList(final Iterable< ? extends HasEmail> list); void sendMail(final Message message); MimeMessage createMessage(); void setTo(final MimeMessage message, final String emailToString); void setCc(final MimeMessage message, final String emailToString); void setBcc(final MimeMessage message, final String emailToString); void setFrom(final MimeMessage message, final String emailFromString); void setReplyTo(final MimeMessage message, final String addressString); void setSubject(final MimeMessage message, final String subject); void setTextBody(final MimeMessage message, final String textBody); void setHtmlBody(final MimeMessage message, final String htmlBody); Part addAttachmentPart(final Message message); Part addAttachmentMessage(final Message message, final Message attachedMessage); }
EmailerFactory { public MimeMessage createMessage() throws MessagingException { Properties mailProps = new Properties(); mailProps.put("mail.transport.protocol", mailTransportProtocol); for (Map.Entry<String, String> cfg : transportConfiguration.entrySet()) { mailProps.put(cfg.getKey(), cfg.getValue()); } Session mailSession = Session.getInstance(mailProps, null); MimeMessage msg = new MimeMessage(mailSession); msg.setSentDate(new Date()); msg.setFrom(new InternetAddress(defaultFromAddress)); msg.setContent(new MimeMultipart("alternative")); return msg; } EmailerFactory(final String inMailTransportProtocol, final Map<String, String> inTransportConfiguration,
            final String inDefaultFromAddress); static String buildEmailList(final Iterable< ? extends HasEmail> list); void sendMail(final Message message); MimeMessage createMessage(); void setTo(final MimeMessage message, final String emailToString); void setCc(final MimeMessage message, final String emailToString); void setBcc(final MimeMessage message, final String emailToString); void setFrom(final MimeMessage message, final String emailFromString); void setReplyTo(final MimeMessage message, final String addressString); void setSubject(final MimeMessage message, final String subject); void setTextBody(final MimeMessage message, final String textBody); void setHtmlBody(final MimeMessage message, final String htmlBody); Part addAttachmentPart(final Message message); Part addAttachmentMessage(final Message message, final Message attachedMessage);  }