cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Email from Web Dynpro

Former Member
0 Kudos

Hi,

I'am new in that business and have a simple question:

What is the easiest way to send emails from a web dynpro application to a specific (e.g. value of an input field in my application).

The only way I found was the "email - web service tutorial in the pdk).

Can anyone give me some code to solve this problem.

Thanx

christoph

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

How abt this .

InitialContext ctx = new InitialContext();

Properties props = new Properties();

props.put("mail.smtp.host","msg server");

Session sess = Session.getInstance(props);

//Create new mime message object

Message message = new MimeMessage(sess);

message.setFrom(new InternetAddress(from email));

String recepient = wdContext.currentContextElement().getTo();

message.setRecipient(Message.RecipientType.TO,new InternetAddress(to email));

message.setSubject(subject);

message.setContent(content,"text/plain");

//Send the message

Transport.send(message);

Regards

Bharathwaj

Message was edited by: Bharathwaj R,Error corrected.Check my next post also!

Former Member
0 Kudos

hi Bharathwaj,

I'm trying your solutions, but I get an error at the line:

......new message.setSubject(subject);

can you really work with new here?

thanx

christoph

Former Member
0 Kudos

Hi,

Sorry ! One sec! I will edit it and do it again !

InitialContext ctx = new InitialContext();

Properties props = new Properties();

props.put("mail.smtp.host","Message server");

Session sess = Session.getInstance(props);

//Create new mime message object

Message message = new MimeMessage(sess);

message.setFrom(new InternetAddress(wdContext.currentContextElement().getFrom()));

String recepient = wdContext.currentContextElement().getTo();

message.setRecipient(Message.RecipientType.TO, new InternetAddress(recepient));

String subject = wdContext.currentContextElement().getSubject();

message.setSubject(subject);

String content = wdContext.currentContextElement().getMessage();

message.setContent(content,"text/plain");

//Send the message

Transport.send(message);

This should work.. (Some editing error while i was pasting it !)

Message was edited by: Bharathwaj R

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Syntax is

InternetAddress[] Toaddress = new InternetAddress[Number];

msg.setRecipients(MimeMessage.RecipientType.TO, Toaddress);

Regards, Anilkumar

Former Member
0 Kudos

Hi Christoph,

Check out this weblog:

/people/renald.wittwer/blog/2005/01/05/develop-a-web-service-that-sends-an-email

Regards,

Pooja.

Former Member
0 Kudos

hi,

there are number of options available, like you can use the java mail framework to create your own mail service and you can use that, or if you have your own mail service configured (like outlook webaccess) you use that too.

regards,

rahul.

Former Member
0 Kudos

Hi,

Easiest way is

1.Create Link to URL

2.create a contextarrtib "reference" and set the reference and text property of linktoURL to this attribute.

3.use this statement in the init method.

wdContext.currentContextElement().setReference("mailto:<EMailID>");

Regards, Anilkumar

Former Member
0 Kudos

Hi

I have tried your solution but when link is clicked nothing is happening

Please elaborate.

Regards

Ananda

former_member182372
Active Contributor
0 Kudos

Hello,

is it not really good for you https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/web dynpro tutorial and sample applications.faq#q-6 ?

Regards, Maksim R.