Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems Sending HTML Email Through TDI

238 views
Skip to first unread message

Kevin McCullough

unread,
Nov 19, 2009, 10:10:47 AM11/19/09
to
I'm able to send plaintext emails through TDI, but I have some data
that I want to format in a table, and I thought HTML would be the best
way to do that. I've marked the problem line with asterisks below.
I've tried many different iterations of that line of code, most of
them ending up with the error:

Unknown member 'RecipientType' in Java Class 'javax.mail.Message'.

OR

Error calling method 'addRecipients(null, string)' on java class
'javax.mail.internet.MimeMessage'.

It didn't appear that TDI has access to the Java variable
javax.mail.Message.RecipientType, so I started trying to use the
getProperty method, which returns null. Has anyone else had this
issue, or can anyone offer any suggestions?

Here's the code that I'm using:
task.logmsg("Sending mail...");
var props = new java.util.Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", smtpServer);
props.setProperty("mail.user", myEmail);
props.setProperty("mail.password", xy);

var mailSession = javax.mail.Session.getDefaultInstance(props,
null);
mailSession.setDebug(true);
var transport = mailSession.getTransport();

var message = new javax.mail.internet.MimeMessage
(mailSession);
message.setSubject("HTML mail with images");
message.setFrom(new javax.mail.internet.InternetAddress
(myEmail));
message.setContent("<h1>Hello world</h1>", "text/html");

// ****** This is the line causing all the problems
message.addRecipients(java.lang.System.getProperty
("javax.mail.Message.RecipientType.TO"), myEmail);

transport.connect();
transport.sendMessage(message,
message.getRecipients(Message.RecipientType.TO));
transport.close();

Thank you!
-Kevin McCullough

Andrew Findlay

unread,
Nov 19, 2009, 12:00:56 PM11/19/09
to
On Nov 19, 3:10 pm, Kevin McCullough <km6...@gmail.com> wrote:

> Unknown member 'RecipientType' in Java Class 'javax.mail.Message'.
>
> OR
>
> Error calling method 'addRecipients(null, string)' on java class
> 'javax.mail.internet.MimeMessage'.

> Here's the code that I'm using:

> // ****** This is the line causing all the problems


> message.addRecipients(java.lang.System.getProperty
> ("javax.mail.Message.RecipientType.TO"), myEmail);

I am not familiar with the Java API that you are using, but it does
look as if you are trying to use the value of a recipient *type* as a
recipient *address*.

Surely the mail recipient address should be a fixed text string, or
come from a TDI variable (not from a javax.mail object)?

Andrew

Kevin McCullough

unread,
Nov 19, 2009, 12:26:52 PM11/19/09
to
On Nov 19, 12:00 pm, Andrew Findlay <andrew.find...@skills-1st.co.uk>
wrote:

Hi Andrew,
Thanks for the reply. Here is the link to the Java API I'm using:
http://java.sun.com/products/javamail/javadocs/javax/mail/Message.html#addRecipients(javax.mail.Message.RecipientType,%20javax.mail.Address[])

It requires 2 parameters, one of which is the RecipientType (TO, CC,
etc) and the other is the address.

Andrew Findlay

unread,
Nov 19, 2009, 2:59:06 PM11/19/09
to
On Nov 19, 5:26 pm, Kevin McCullough <km6...@gmail.com> wrote:

> Here is the link to the Java API I'm using:http://java.sun.com/products/javamail/javadocs/javax/mail/Message.htm...[])


>
> It requires 2 parameters, one of which is the RecipientType (TO, CC,
> etc) and the other is the address.

Ah - I don't think Message.RecipientType.TO is actually a variable.
Looks more like a method, so try something like this:

message.addRecipients(Message.RecipientType.TO, myEmail);

See http://java.sun.com/products/javamail/javadocs/javax/mail/Message.RecipientType.html

Andrew

Kevin McCullough

unread,
Nov 19, 2009, 3:39:05 PM11/19/09
to
On Nov 19, 2:59 pm, Andrew Findlay <andrew.find...@skills-1st.co.uk>
wrote:
> Seehttp://java.sun.com/products/javamail/javadocs/javax/mail/Message.Rec...
>
> Andrew

Here's the latest error message:
Java method 'addRecipients(Message.RecipientType.TO, string)' on java
class 'javax.mail.internet.MimeMessage' not found.

I changed the line: message.addRecipients(Message.RecipientType.TO,
myEmail); to include my email address as a string, removing the
myEmail reference, but it still doesn't work. Here is the API I'm
going for:
http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeMessage.html#addRecipients(javax.mail.Message.RecipientType,%20java.lang.String)

Again, any help is greatly appreciated.

Eddie Hartman

unread,
Nov 25, 2009, 5:04:38 PM11/25/09
to
Have you tried using the SendMail Function component, or
system.sendMail(), Kevin. Might be simpler.

-Eddie

P.S. Sorry for the belated reply

Kevin McCullough

unread,
Nov 30, 2009, 9:13:07 AM11/30/09
to
> > -Kevin McCullough- Hide quoted text -
>
> - Show quoted text -

Hi Eddie,

Yes, I was able to get system.SendMail working, and that's what I've
been using. However, this doesn't allow me to send in HTML, does it?

Eddie Hartman

unread,
Dec 3, 2009, 5:01:50 AM12/3/09
to
Just to let the community know: Kevin and I have had a few
email exchanges and he is now bringing this up with our
Wizards of L2. Stay tuned for more...

-Eddie

Reena Christy

unread,
Oct 20, 2015, 7:08:55 AM10/20/15
to
Hi Eddie,

Im facing the same issue now. Can you please let me know how this issue was resolved by your L2 team.

Jason Williams

unread,
Oct 22, 2015, 10:29:59 AM10/22/15
to
On Tuesday, October 20, 2015 at 6:08:55 AM UTC-5, Reena Christy wrote:
> Hi Eddie,
>
> Im facing the same issue now. Can you please let me know how this issue was resolved by your L2 team.

I only see system.sendmail() using Content-Type: text/plain
Have you looked at using the SendMailFC? It gives you the option to set the MIME content type.
0 new messages