on 01-22-2010 11:02 AM
Hi Experts,
I am using Javax.mail API to send an email through java application. But i am facing an issue when i am deploying the java application in SAP WAS.
I have assigned values in SMTP Host ,Port, and InternetAddress and deployed to WAS. But when i deploy this java class again in WAS with changing the values for SMTP Host ,Port and InternetAddress and putting in Properties object ,its always picking the values set at first time.
Can anyone tell me whats wrong with following code .
Properties prpt = new Properties();
if (host == null)
{
host=token[0];
}
prpt.put("mail.smtp.host",host);
prpt.put("mail.smtp.sendpartial", "true");
if (port == null)
{
port=token[1];
}
prpt.put("mail.smtp.port", port);
Session session1=Session.getDefaultInstance(prpt, null);
MimeMessage message=new MimeMessage(session1);
message.setFrom(new InternetAddress(emailId"));
Thanks in advance.
The problem is caused due to the way you get the Session instance: By using the method getDefaultInstance your property values don't matter once the method was executed once. Just try replacing in your code the call to getDefaultInstance with the following:
// Session session1=Session.getDefaultInstance(prpt, null);
// Replace with
Session session1=Session.getInstance(prpt, null);
Cheers, harald
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.