cancel
Showing results for 
Search instead for 
Did you mean: 

Send attachments with Email in WebDynpro[Java]

Former Member
0 Kudos

Hi All,

Developing a webdynpro application in Java Which will sending -mail.Is it Possible to send attachments[Ex: Excel/doc Files] in webdynpro ?How to do it ?Please Help me out..

Regards,

Ramganesh.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Try this code;

Properties properties = new Properties();

properties.put( "mail.smtp.host", <>);

Session session = Session.getInstance( properties, null);

MimeMessage message = new MimeMessage( session);

try

{

MimeMultipart multipart = new MimeMultipart();

BodyPart messageBodypart = new MimeBodyPart();

message.setFrom( new InternetAddress( <sender mail id>));

message.setRecipient( Message.RecipientType.TO, new InternetAddress( wdContext.currentContextElement().getP_Email_Id()));

message.setSubject( "Subject");

messageBodypart.setText( "Text");

multipart.addBodyPart( messageBodypart);

messageBodypart = new MimeBodyPart();

messageBodypart.setDataHandler( new DataHandler( new FileDataSource( <Path of file>)));

messageBodypart.setFileName( new FileDataSource( <Path of file>).getName());

messageBodypart.setHeader( "Content-Type", "application/pdf");

multipart.addBodyPart( messageBodypart);

message.setContent( multipart);

Transport.send( message);

} catch (AddressException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (MessagingException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

Regards

Vinod V

sureshmandalapu6
Active Contributor
0 Kudos

Hi Ramganesan Karuppaiyah ,

refer the following links

[http://help.sap.com/erp2005_ehp_03/helpdata/EN/8d/6bd83e8cb23d67e10000000a114084/frameset.htm|http://help.sap.com/erp2005_ehp_03/helpdata/EN/8d/6bd83e8cb23d67e10000000a114084/frameset.htm]

[https://forums.sdn.sap.com/click.jspa?searchID=1063990&messageID=1486766|https://forums.sdn.sap.com/click.jspa?searchID=1063990&messageID=1486766]

[|]

[|]

points if useful

thanks

suresh