cancel
Showing results for 
Search instead for 
Did you mean: 

Send attachment through Email

Former Member
0 Kudos

Hi All,

I have a scenario where on Action Submit the uploaded file must send as an e-mail to the given recipient.

I'm able to create the application till uploading file but could not send this as an attachment through e-mail.

Could any one help in this regards.

It is very urgent.

Thanks in advance

ambicasony

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi All,

Could any help me in other way of sending an email on click on button.

regards

ambicasony

Former Member
0 Kudos

hai ambica,

I have sent the jar files to your mail .If these jar files are included the coding given by me ll work.check and let me know if there are any issues.

Thanks n Regards

Sharanya.R

Edited by: Sharanya.R on Mar 6, 2008 9:42 AM

Former Member
0 Kudos

Hi Sharanya,

I'm still unable to send the mail.

I have tried the sample tutorial given in SDN(sending offline interactives forms)

But still no luck.

Could you help me in just sending an mail without any attachment.

please help me.

Regards

ambicasony

Edited by: ambica sony on Mar 6, 2008 12:17 PM

Former Member
0 Kudos

Hi,

Just open the below link.

check page 9 and 10 it will clear your problem.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-tec...

Regards,

Naga

Former Member
0 Kudos

Hi

I have tried this tutorial.

When i deploy the application it gives an Exception as "client not authenticated"

regards

ambicasony

Former Member
0 Kudos

Hi,

Dont try to execute the application, to send an email attachment follow the procedure described in the pages 9 and 10.It will work

To execute that tutorial you need to have adobe authorizations in j2ee

server.

Regards,

Naga

Former Member
0 Kudos

Hi

I have tried the application only to send an email without attachment.

Exception :

Sending failed; nested exception is: javax.mail.AuthenticationFailedException

regards

ambicasony

Edited by: ambica sony on Mar 6, 2008 12:45 PM

Former Member
0 Kudos

hi

Properties props = System.getProperties();

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

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

Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress("give from mail id"));

msg.setRecipients(Message.RecipientType.TO,

InternetAddress.parse("to mail id", false));

msg.setSubject("<subject>");

msg.setText("body");

Transport.send(msg);

Regards,

Naga

Former Member
0 Kudos

Hi,

Please check ur mail, i sent you a sample app which i have.

Regards,

Naga

Former Member
0 Kudos

I have tried but could run your application.

Former Member
0 Kudos

hai ambica,

In the code that i have sent you the content of mime 1 ll go as content and mime part2 ll go as attachment so delete the 2 and try once.

Thanks n Regards Sharanya.R

Former Member
0 Kudos

Hi Sharanya..

I have tried only with partI and used the following code

Properties props = new Properties();

String host = "<IP address>";

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

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

MimeMessage message = new MimeMessage(session);

message.setFrom(new InternetAddress("<Email ID>"));

message.addRecipient(Message.RecipientType.TO, new InternetAddress(wdContext.currentContextElement().getMailId()));

message.setSubject("Notification");

message.setText("Notification");

Transport.send(message);

But there no errors & the mail is not sent and gives exception as "Client not Authntictaed"

regards

ambicasony

Former Member
0 Kudos

Hi,

did you give the proper smtp IP address?

Regards,

Naga

Former Member
0 Kudos

yes..I have given the proper IP address and the email id, but no luck.

Problem is with some authentication.

Do i need write any code for authenication ?

Former Member
0 Kudos

Hi,

I think there is no need to provide authentication, can you tell me what your application will do? what UI elements you are using?

Regards,

Naga

Former Member
0 Kudos

Hi Nagaraju,

Problem solved.

Thanks a lot....................

10 points awarded for you.........:)

Cheers

ambicasony

Former Member
0 Kudos

Hi

I am facing the same problem ....can u tell me how did u solve it???

Thank You

Ishita

Answers (4)

Answers (4)

Former Member
0 Kudos

Problem is resolved.

Thanks to all of you.

Former Member
0 Kudos

hi ambika,

can u give me ur code please. i am getting this exception javax.mail.AuthenticationFailedException

regards,

harsha

Former Member
0 Kudos

hai ambica,

To use the code i have given you need to import 2 jar files

1.smtp.jar

2.mail.jar

let me know if you face any issues with the code ive given.

Thanks n regards

Sharanya.R

Former Member
0 Kudos

Hi Sharanya,

Thank you for your quick reply.

Could you let me know where can I find this jar files.

Do i need to do any thing else with this files.

Please let me know.

Definately I will reward with you full points.

regards

ambicasony

Former Member
0 Kudos

Hi Ambica

I found mail.jar on my system at this location :

C:/Program Files/SAP/IDE/IDE70/eclipse/plugins/com.sap.ext.libs.webservices_2.0.0/lib/mail.jar

You also try at your side..

Thanks

Monika

Former Member
0 Kudos

Hi Sharanya,

I have tried your code. I'm not getting any error but the mail is not set and also i'm unable to find SMTP.jar file.

Could please help me.

Regards

ambicasony

Former Member
0 Kudos

Hi,

You can download this from http://java.sun.com/products/javamail/downloads/index.html

Regards

Ayyapparaj

Former Member
0 Kudos

hai ambica the problem will be due to the missing jar files only.give me your mail id ill send the two jar files.

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi Sharanya,

please send to this email id ambicasony@gmail.com

Regards

ambicasony

Former Member
0 Kudos

hai Ambica,

put this coding inside a method and call that on the on Action property of button.

When give mime body part 2 it ll go as attachment.try this it will work.

try

{

String strSMTPIPAddress ="192.168.100.103";

Properties props;

Session session;

Provider p;

props = System.getProperties();

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

session = Session.getDefaultInstance(props, null);

StringBuffer strMailBody = new StringBuffer();

wdThis.createmailbody(strMailBody);

Message message = new MimeMessage(session);

message.setFrom(new InternetAddress("<give the email address here>"));

message.addRecipient(Message.RecipientType.TO, new InternetAddress("<email address>"));

message.setSubject("<give the subject of mail>");

MimeMultipart mimemultipart = new MimeMultipart();

// //set message content

//this is body content

MimeBodyPart mimebodypart1=new MimeBodyPart();

//This is attachmnent

MimeBodyPart mimebodypart2=new MimeBodyPart();

// mimebodypart1.setText("xxx"); //Attachment

mimebodypart2.setText("<give the content of attachemnt>');

mimemultipart.addBodyPart(mimebodypart1);

mimemultipart.addBodyPart(mimebodypart2);

//message.setText(wdContext.currentContextElement().getSalorder());

message.setContent(mimemultipart);

message.setText(strMailBody.toString());

Transport.send(message);

wdComponentAPI.getMessageManager().reportSuccess("E-mail is sent to sharanya");

}

catch (Exception e)

{

wdComponentAPI.getMessageManager().raiseException("Exception" + e.getMessage(), true);

}

If you have any issues in using this plz let me know.

Thanks n Regards

Sharanya.R

Edited by: Sharanya.R on Mar 4, 2008 9:45 AM

Edited by: Sharanya.R on Mar 4, 2008 9:56 AM

Former Member
0 Kudos

Hi sharanya,

what is this "wdThis.createmailbody(strMailBody);" am getting error over here.

regards,

harsha

Former Member
0 Kudos
Former Member
0 Kudos

Hi

Thanks for your quick response.

I have already red this post, but could able to understand.

Could you help in giving the code.

Regards

ambicasony

Former Member
0 Kudos

Hi ambica

Refer to this pdf

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

and the following thread also:

May be it can help

Thanks

Monika