on 05-16-2007 8:36 AM
Hi friends,
I am having a scenario in my application to send a mail . i am following the below code .I am not facing any errors but mail is not sent. even my SMTP host name also correct.
try{
InitialContext ctx = new InitialContext();
Properties props = new Properties();
props.put("mail.smtp.host","172.16.22.14");
Session sess = Session.getInstance(props);
Message message = new MimeMessage(sess);
message.setFrom(new InternetAddress(wdContext.currentContextElement().getCreatedBy()+"@accenture.com"));
String recepient = "ratnakar.r.alwala@accenture.com";
message.setRecipient(Message.RecipientType.TO, new InternetAddress(recepient));
String subject = wdContext.currentTasksBeanElement().getType();
message.setSubject(subject);
String content = wdContext.currentTasksBeanElement().getDescription();
message.setContent(content,"text/plain");
// Send the message
Transport.send(message);
msgMgr.reportSuccess(" Mail has been sent successfully");
}catch(Exception e)
{
msgMgr.reportSuccess(" Error occured in Email Sending"+e.getMessage());
}
could any body please look in to this and reply ASAP
Thanks and regards
Ratnakar reddy
Hi Ratnakar,
Check the value of wdContext.currentContextElement ().getCreatedBy()
wdComponentAPI.getMessageManager().reportSuccess("Created By : "+ wdContext.currentContextElement().getCreatedBy());
what value you are getting is there any email id exists using that name.
Regards,
Mithu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
logon on the Visual Admin and check in the <b>Java Mail</b> Service if your SMTP service is setting up.
After this stop and restart that Service.
Reward points for helpful answers.
Best regards,
Gianluca Barile
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In addition to the ongoing thread, can somobody answer a simple question of mine?
Assuming the SMTP setup is done in Visual Admin, now coming to the code part, what should the Properties object be populated with?
Should I use
Session session = Session.getInstance(new Properties());
or
Session session = Session.getDefaultInstance(new Properties());
Please note, its an empty Properties object. Do I need to populate it again with the smtp server defined in Visual Admin?
Thanks,
Rajit
Hai ,
Try this one
try
{
Properties props = System.getProperties();
props.put("mail.smtp.host","172.16.22.14");
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(wdContext.currentContextElement().getCreatedBy()+"@accenture.com"));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("ratnakar.r.alwala@accenture.com", false));
msg.setSubject(wdContext.currentTasksBeanElement().getType());
msg.setText(wdContext.currentTasksBeanElement().getDescription());
msg.setHeader("X-Mailer", "Email");
msg.setSentDate(new Date());
Transport.send(msg);
msgMgr.reportSuccess("Message sent OK.");
}
catch (Exception ex)
{
ex.printStackTrace();
}
Regards,
Naga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.