cancel
Showing results for 
Search instead for 
Did you mean: 

How to send mail through WebDynpro Application

Former Member
0 Kudos

Hi All,

How can I send mail through WebDynpro application that includes an HTML content?

Thanks,

Aviad

Accepted Solutions (1)

Accepted Solutions (1)

Sigiswald
Contributor
0 Kudos

Hi Aviad,

Personally I'd use the <a href="http://jakarta.apache.org/commons/email/">Commons Email</a> API. I don't know if SAP also provides a nice API.

Kind regards,

Sigiswald

Former Member
0 Kudos

Thanks, it seems really good, but did anyone use it in WebDynpro?

Thanks,

Aviad

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

you can follow this link relating to email

https://www.sdn.sap.com/irj/sdn/collaboration as it has been raised regarding same topic

Regards

Radhika Kuthiala

P.S Do award points for encouragement:)

former_member189631
Active Contributor
0 Kudos

Hi Aviad,

Please use this ldocument link to send emails,

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cacb9a7d-0c01-0010-1281-be4962c9...

Regards,

Ramganesan K.

Former Member
0 Kudos

AVIAD RIVLIN ,

import java.util.*;

import javax.mail.*;

import javax.mail.internet.*;

import java.util.ResourceBundle;

public boolean sendMessage(String fromID, String toID, String mailSubject,

String mailBody) {

// Write mail sending logic here

ResourceBundle dbproperties = ResourceBundle.getBundle("mention the property file name");

String from = fromID;

String to = toID;

String subject = mailSubject;

String body = mailBody;

String dbhost = dbproperties.getString("MailServer");

String host = dbhost;

// create some properties and get the default Session

try {

Properties props = new Properties();

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

Session session = Session.getDefaultInstance(props, null);

// create a message

Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(from));

InternetAddress[] address = { new InternetAddress(to) };

msg.setRecipients(Message.RecipientType.TO, address);

msg.setSubject(subject);

msg.setSentDate(new Date());

msg.setText(body);

Transport.send(msg);

// System.out.println("Mail has been sent");

// if mail sent , return true, else return false

return true;

} catch (Exception mex) {

System.out.println("Error " + mex);

return false;

}

}// end of sendMail...

}

regards

Anil Dichpally

Former Member
0 Kudos

Thanks again, this looks good, but how can I add an HTML file with icons and images to this mail.

Thanks a lot!

Aviad

Former Member
0 Kudos

You can use the following for sending attachments :

BodyPart messageBodyPart = new MimeBodyPart();

messageBodyPart.setText(Attachment);

Multipart multipart = new MimeMultipart();

multipart.addBodyPart(messageBodyPart);

messageBodyPart = new MimeBodyPart();

DataSource source = new FileDataSource(Attachment);

messageBodyPart.setDataHandler(new DataHandler(source));

messageBodyPart.setFileName(Attachment);

multipart.addBodyPart(messageBodyPart);

msg.setContent(multipart);

Regards, Anilkumar

Sigiswald
Contributor
0 Kudos

That's exactly what Commons Email makes easy Check the topic "Sending HTML formatted email" in the <a href="http://jakarta.apache.org/commons/email/userguide.html">User guide</a>.

It should be straightforward to use from within Web Dynpro. Store the necessary jar file(s) in an External Library DC. Another option is always to copy/paste (parts of) the source code, but that seems a bit of an ugly approach.

Kind regards,

Sigiswald