Address[] recipients = requestMessage.getRecipients(Message.RecipientType.TO);
if (!ObjectUtils.isEmpty(recipients) && recipients[0] instanceof InternetAddress) {
return MailTransportUtils.toUri((InternetAddress) recipients[0], requestMessage.getSubject());
}
else {
throw new URISyntaxException("", "Could not determine To header");
}
}
catch (MessagingException ex) {
throw new URISyntaxException("", ex.getMessage());
}
}