on 2007 Feb 08 3:43 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Shami,
please use following link
https://wwwn.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/b040e6cd-0401-0010-268d-f67cf4904358
Eith Regards
Naidu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check my reply here
https://forums.sdn.sap.com/click.jspa?searchID=1091522&messageID=619448
Regards, ANilkumar
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.
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
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.
User | Count |
---|---|
59 | |
11 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.