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
> 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
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.
> 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
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
P.S. Sorry for the belated reply
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