cancel
Showing results for 
Search instead for 
Did you mean: 

Send mail with attachment from webdynpro application

Former Member
0 Kudos

hi,

From a webdynpro application, the user will upload any files through the File upload ui element.These uploaded files has to go as an attachment in the mail which is being send to a particular ID ,when the user clicks the submit button in the form.

can you please give me the code regarding this and help me in sending mail with attachment from a webdynpro application.

Thanks in advance,

shami.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hai,

Properties props = System.getProperties();
	  props.put("mail.smtp.host", "xx.xx.x.xx");
	  Session session = Session.getDefaultInstance(props, null);
	  Message msg = new MimeMessage(session);
	  msg.setFrom(new InternetAddress("some@some.net"));
	  msg.setRecipients(Message.RecipientType.TO,
	  InternetAddress.parse("some@some.net", false));
	  msg.setSubject(subject);
	  msg.setText(body);
	  msg.setHeader("X-Mailer", " Email");
	  msg.setSentDate(new Date());
	  
	  MimeBodyPart messageBodyPart = new MimeBodyPart();
	  messageBodyPart.setText("Hai , This mail Generated By the  Program");
      Multipart multipart = new MimeMultipart();
	  multipart.addBodyPart(messageBodyPart);
	   messageBodyPart = new MimeBodyPart();
	   DataSource source = new FileDataSource("C:\nag.xls");//Here you need to give the Path of uploaded File 
	   messageBodyPart.setDataHandler( new DataHandler(source));
	   messageBodyPart.setFileName("nag.xls");
	   multipart.addBodyPart(messageBodyPart);

	   // Put parts in message
	   msg.setContent(multipart);

	  Transport.send(msg);

Regards,

Naga

Former Member
0 Kudos
Former Member
0 Kudos

hi,

I want to sent any file uploaded from file upload ui element in webdynpro.And not always a specific file store in mimes.

please help..

Thanks in advance,

shami.

Former Member
0 Kudos

Hi Shami,

Pl check my weblog /people/anilkumar.vippagunta2/blog/2007/02/04/office-control-in-webdynpro-ii where i have explained about this.

Regards,Anilkumar

Former Member
0 Kudos

hi,

I have to upload the files using webdynpro ui element and send the uploaded files as attachment in mail when the user clicks on a button in the form

Please help...

Thanks in advance,

shami.

Former Member
Former Member
0 Kudos

hi,

I am not able to link to

https://forums.sdn.sap.com/click.jspa?searchID=1091522&messageID=619448

please provide me a correct link.

Thanks in advance,

shami.

Former Member
0 Kudos

Check this link

Regards, ANilkumar

Former Member
0 Kudos

Message msg = new MimeMessage(mailsession);

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);

msg.setSubject(Subject);

msg.setText(Message);

Transport.send(msg);

Regards,Anilkumar

Former Member
0 Kudos

hi,

In the code

Message msg = new MimeMessage(mailsession);

BodyPart messageBodyPart = new MimeBodyPart();

messageBodyPart.setText(<b>Attachment</b>);

Multipart multipart = new MimeMultipart();

multipart.addBodyPart(messageBodyPart);

messageBodyPart = new MimeBodyPart();

DataSource source = new FileDataSource(<b>Attachment</b>);

messageBodyPart.setDataHandler(new DataHandler(source));

messageBodyPart.setFileName(Attachment);

multipart.addBodyPart(messageBodyPart);

msg.setContent(multipart);

msg.setSubject(Subject);

msg.setText(Message);

Transport.send(msg);

What is the type of the ATTACHMENT object....

I am asking its data type...

It is not declared or initialised in the code..

Please tell me to proceed futrher.

Please help.

Thanks in advance,

shami.

Former Member
0 Kudos

Did you ever get a response to this question or determine what Attachment is? I am getting java exceptions saying the attachment cannot be found so I think I'm missing a step between uploading to the context and creating the Attachment variable.