Search in sources :

Example 66 with InternetAddress

use of javax.mail.internet.InternetAddress in project OpenClinica by OpenClinica.

the class CoreSecureController method processMultipleImailAddresses.

private InternetAddress[] processMultipleImailAddresses(String to) throws MessagingException {
    ArrayList<String> recipientsArray = new ArrayList<String>();
    StringTokenizer st = new StringTokenizer(to, ",");
    while (st.hasMoreTokens()) {
        recipientsArray.add(st.nextToken());
    }
    int sizeTo = recipientsArray.size();
    InternetAddress[] addressTo = new InternetAddress[sizeTo];
    for (int i = 0; i < sizeTo; i++) {
        addressTo[i] = new InternetAddress(recipientsArray.get(i).toString());
    }
    return addressTo;
}
Also used : StringTokenizer(java.util.StringTokenizer) InternetAddress(javax.mail.internet.InternetAddress) ArrayList(java.util.ArrayList)

Example 67 with InternetAddress

use of javax.mail.internet.InternetAddress in project OpenClinica by OpenClinica.

the class SecureController method processMultipleImailAddresses.

private InternetAddress[] processMultipleImailAddresses(String to) throws MessagingException {
    ArrayList<String> recipientsArray = new ArrayList<String>();
    StringTokenizer st = new StringTokenizer(to, ",");
    while (st.hasMoreTokens()) {
        recipientsArray.add(st.nextToken());
    }
    int sizeTo = recipientsArray.size();
    InternetAddress[] addressTo = new InternetAddress[sizeTo];
    for (int i = 0; i < sizeTo; i++) {
        addressTo[i] = new InternetAddress(recipientsArray.get(i).toString());
    }
    return addressTo;
}
Also used : StringTokenizer(java.util.StringTokenizer) InternetAddress(javax.mail.internet.InternetAddress) ArrayList(java.util.ArrayList)

Example 68 with InternetAddress

use of javax.mail.internet.InternetAddress in project OpenClinica by OpenClinica.

the class EmailEngine method processHtml.

public void processHtml(String to, String from, String subject, String body) throws MessagingException {
    InternetAddress from2 = new InternetAddress(from);
    message.setFrom(from2);
    // InternetAddress to2 = new InternetAddress(to);
    // message.addRecipient(Message.RecipientType.TO, to2);
    message.addRecipients(Message.RecipientType.TO, processMultipleImailAddresses(to));
    message.setSubject(subject);
    // YW <<
    mbp.setContent(body, "text/html");
    // YW >>
    mm.addBodyPart(mbp);
    message.setContent(mm);
    Transport.send(message);
}
Also used : InternetAddress(javax.mail.internet.InternetAddress)

Example 69 with InternetAddress

use of javax.mail.internet.InternetAddress in project OpenClinica by OpenClinica.

the class EmailEngine method process.

public void process(String to, String from, String subject, String body) throws MessagingException {
    InternetAddress from2 = new InternetAddress(from);
    message.setFrom(from2);
    // InternetAddress to2 = new InternetAddress(to);
    // message.addRecipient(Message.RecipientType.TO, to2);
    message.addRecipients(Message.RecipientType.TO, processMultipleImailAddresses(to));
    message.setSubject(subject);
    // YW <<
    mbp.setContent(body, "text/plain");
    // YW >>
    mm.addBodyPart(mbp);
    message.setContent(mm);
    Transport.send(message);
}
Also used : InternetAddress(javax.mail.internet.InternetAddress)

Example 70 with InternetAddress

use of javax.mail.internet.InternetAddress in project opennms by OpenNMS.

the class JavaMailer method initializeMessage.

/**
     * Helper method to that creates a MIME message.
     * @param session
     * @return
     * @throws MessagingException
     * @throws AddressException
     */
private MimeMessage initializeMessage() throws MessagingException, AddressException {
    MimeMessage message;
    message = new MimeMessage(getSession());
    message.setFrom(new InternetAddress(getFrom()));
    message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(getTo(), false));
    message.setSubject(getSubject(), m_charSet);
    for (final String key : getExtraHeaders().keySet()) {
        message.setHeader(key, m_extraHeaders.get(key));
    }
    return message;
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) MimeMessage(javax.mail.internet.MimeMessage)

Aggregations

InternetAddress (javax.mail.internet.InternetAddress)255 MimeMessage (javax.mail.internet.MimeMessage)106 MessagingException (javax.mail.MessagingException)69 Session (javax.mail.Session)49 Properties (java.util.Properties)45 ArrayList (java.util.ArrayList)42 Address (javax.mail.Address)41 Message (javax.mail.Message)40 Date (java.util.Date)38 JavaMailInternetAddress (com.zimbra.common.mime.shim.JavaMailInternetAddress)36 AddressException (javax.mail.internet.AddressException)34 X509Certificate (java.security.cert.X509Certificate)32 MimeBodyPart (javax.mail.internet.MimeBodyPart)30 Test (org.junit.Test)29 IOException (java.io.IOException)26 MimeMultipart (javax.mail.internet.MimeMultipart)26 PolicyExpression (org.nhindirect.policy.PolicyExpression)18 HashMap (java.util.HashMap)17 CertificateResolver (org.nhindirect.stagent.cert.CertificateResolver)17 PolicyResolver (org.nhindirect.stagent.policy.PolicyResolver)17