cancel
Showing results for 
Search instead for 
Did you mean: 

Mailing throw webdynpro for java

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI bavani..

Chk thiss link..

http://www.atlassian.com/software/jira/docs/latest/smtpconfig.html

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b9ea34c2-0701-0010-e2a2-d8e9cd6d...

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

Former Member
0 Kudos

Thanks Sathishkumar,

We need to configure the mail server in NW2004S SAP EP 7.0 SP9.Can you please send any document or guide us how to configure this.

Regards,

Bhavani

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi sateesh,

Any how i am trying this one and i am not getting it. I am getting the error as unknown SMTP host and java.net.UnknownHostException.

I conform that the host name is right.What to do.

Former Member
0 Kudos

I import only mail.jar file in to my webdynpro applicaion.Then also i am not able to send the mail.So are there any files which are add to my wd for completing the task.

Former Member
0 Kudos

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

Answers (0)