Example usage for javax.mail.internet AddressException getLocalizedMessage

List of usage examples for javax.mail.internet AddressException getLocalizedMessage

Introduction

In this page you can find the example usage for javax.mail.internet AddressException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:yoyo.framework.enterprise.infra.messaging.MailServiceImpl.java

/**
 * ??//from w  w w  . jav a 2 s.  c o m
 * @param from FROM
 * @param to TO
 * @param subject ??
 * @return 
 * @throws EnterpriseException ??
 */
private Message createMessage(final String from, final String to, final String subject)
        throws EnterpriseException {
    Validate.notNull(session, "????????");
    try {
        final Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(from));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject(subject);
        return message;
    } catch (final AddressException e) {
        throw new EnterpriseException(e.getLocalizedMessage());
    } catch (final MessagingException e) {
        throw new EnterpriseException(e.getLocalizedMessage());
    }
}