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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations