I am migrating some code from Sun's JavaMail to Geronimo's JavaMail
implementation. The code is identical, but I have changed the library
dependency from Sun JavaMail to Geronimo JavaMail.
However, Geronimo JavaMail now sends out the emails with a blank subject
line. Does anyone have any ideas about how to set the email subject line
using geronimo javamail? I have included my code sample below.
Thanks!
import java.util.Date;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class Mailer {
public boolean sendMail(String recipient, String message) {
Properties props = new Properties();
props.put("mail.smtp.host", "mailserver.company.com");
Session session = Session.getInstance(props);
try {
Message msg = new MimeMessage(session);
//Set message attributes
msg.setFrom(new InternetAddress("[email protected]"));
InternetAddress[] address = {new InternetAddress(recipient)};
msg.setRecipients(Message.RecipientType.TO, address);
// setting the subject line!
msg.setSubject("Subject Line");
msg.setSentDate(new Date());
msg.setText(message);
Transport.send(msg);
}
catch (MessagingException x) {
x.printStackTrace();
}
return true; }
}
--
View this message in context:
http://www.nabble.com/Geronimo-Javamail%3A-Email-Subject-Line-Blank-tp21938752s134p21938752.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.