on 09-06-2007 12:54 PM
Hi Experts,
I want to send the email throw my webdynpro application.i am using this code.
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class Mailer
{
public String to,from,subj,mess,cc;
public boolean retrcpt;
private Logger log;
public Mailer()
{
to="";
from="";
subj="";
mess="";
cc="";
retrcpt=false;
log=new Logger();
}
public boolean doMail()
{
try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", "160.84.32.6");
Session s = Session.getDefaultInstance(props, null);
s.setDebug(true);
Message msg = new MimeMessage(s);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
if(cc!=null)
msg.setRecipients(Message.RecipientType.CC,InternetAddress.parse(cc, false));
msg.setSubject(subj);
msg.setText(mess);
if(retrcpt) msg.setHeader("Disposition-Notification-To",""+to);
Transport.send(msg);
return true;
}
catch(Exception e)
{
log.errLog("Exception while sending mail to "to" by "from" * "+e.toString());
return false;
}
}
}
My problem is that
Where to download the "import javax.mail.*;"file and where and how to install it.
(ii)And also tell me how to configer the SMTP server for the above need.
Advance Thanx
HI bavani..
Chk thiss link..
http://www.atlassian.com/software/jira/docs/latest/smtpconfig.html
http://java.sun.com/products/javamail/downloads/index.html --> <u><b>this link is for downloading..</b></u>
Then u have to download and add jar file...
That file having jar file no need to intall just import ur project..
Then u can access all class files...
Hop this will helpful for u..
Urs GS
Message was edited by:
Sathishkumar GS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,,
r u using Java mailAPI?
If u are using this,
Then u no need to configure mail server..
For tht u jus download the JAR files and Import it to your WD project Library...
If u done this, then u can use All classes in java mailAPI's ...
If u do the abve process then u can do send or receive mails...
Hop this will helpful for u..
Regards GS
Hi Bhavani,
Are you using java mail API to send a mail from your webdynpro application ? if yes you have have to add external jar files i.e mail.jar , activation.jar files to your webdynpro application. please find that below code snippet which i used in my application where the mail is working properly ...
these are the required import packages....
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
......................................................
public void sendEmail( )
{
//@@begin sendEmail()
IWDMessageManager msgMgr=wdComponentAPI.getMessageManager();
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(wdContext.currentTasksBeanElement().getAssignedBy()+"@accenture.com", false));
msg.setRecipients(Message.RecipientType.CC,InternetAddress.parse(wdContext.currentContextElement().getCreatedBy()+"@accenture.com",false));
msg.setSubject("Task 00"wdContext.currentTasksBeanElement().getTaskNo()"-"+wdContext.currentTasksBeanElement().getType());
msg.setText("Hi"'\n'"The following task is assigned to you"'\n'wdContext.currentTasksBeanElement().getDescription());
msg.setHeader("X-Mailer", "Email");
Transport.send(msg);
}
catch (Exception ex)
{
ex.printStackTrace();
}
//@@end
}
but make sure the SMTP port number. If you are implementing this inside your company ask your portal adminstrator or network administrator to get SMTP port number:Still if you are facing any problem ....keep in touch at any time..
Thanks and regards
Ratnakar reddy
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.