You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by DavidCAIT <dz...@cait.org> on 2009/02/10 18:39:22 UTC

Geronimo Javamail: Email Subject Line Blank

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("support@company.com"));
        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.


Re: Geronimo Javamail: Email Subject Line Blank

Posted by DavidCAIT <dz...@cait.org>.
I tried the new JAR and the problem went away. For reference, my old geronimo
JAR had a pom file listing version 1.2.


Jarek Gawor-2 wrote:
> 
> Which version of Geronimo JavaMail are you using? Can you try with
> latest code:
> http://people.apache.org/repo/m2-snapshot-repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/1.7-SNAPSHOT/
> ?
> 
> Thanks,
> Jarek
> 
> On Tue, Feb 10, 2009 at 12:39 PM, DavidCAIT <dz...@cait.org> wrote:
>>
>> 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("support@company.com"));
>>        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.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Geronimo-Javamail%3A-Email-Subject-Line-Blank-tp21938752s134p21943498.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Geronimo Javamail: Email Subject Line Blank

Posted by Jarek Gawor <jg...@gmail.com>.
Which version of Geronimo JavaMail are you using? Can you try with
latest code: http://people.apache.org/repo/m2-snapshot-repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/1.7-SNAPSHOT/
?

Thanks,
Jarek

On Tue, Feb 10, 2009 at 12:39 PM, DavidCAIT <dz...@cait.org> wrote:
>
> 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("support@company.com"));
>        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.
>
>