@CodeCompletion
public Message prepareMessage() throws WGMailException, MessagingException, AddressException {
try {
Session session = _mailConfig.createMailSession();
if (session == null) {
throw new WGMailException("MAIL ERROR: Can't open session.");
}
// Set headers of the mail
MimeMessage message = new MimeMessage(session);
message.setFrom(_from);
// message.setReplyTo( Address[] );
/*
* Could use alias names: Address address = new
* InternetAddress("president@whitehouse.gov", "Barack Obama");
*/
if (_to != null && !_to.isEmpty()) {
message.addRecipients(Message.RecipientType.TO, _to.toArray(new InternetAddress[_to.size()]));
}
else {
throw new WGMailException("MAIL ERROR: No address to send mail to.");
}
if (_cc != null && !_cc.isEmpty()) {
message.addRecipients(Message.RecipientType.CC, _cc.toArray(new InternetAddress[_cc.size()]));