cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Email on click of a button

Former Member
0 Kudos

Hi,

My scenario is like this :

I have a webdynpro application already developed and some values are being fetched from R3. Now, when user clicks on Get data button, he gets all the values from R3.

I need to put a separate button over there and on click of which the email should go to the user logged in to portal (to his email id which is maintained in User Administrator). The data should also go in one pdf format to his mail.

Please help me with this.

Thanks & Regards,

Nikesh

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Use "Adobe Interactive Forms".

There are several tutorials - look for the "online scenario" example.

Former Member
0 Kudos

Hi Aviad,

But how this will capture the Email ids of the User from User admin?

Former Member
0 Kudos

Hi,

Please have a look at this thread

You can get the email id of the logged on user using

IWDClientUser clientuser=WDClientUser.getCurrentUser();

IUser user=clientuser.getSAPUser();

String email=user.getEmail();

You can traverse all the users like this.

Regards,

Saravanan K

Former Member
0 Kudos

Hi Saravanan,

I have seen the thread, but dont know exactly what code I need to write in my method. Email ids I can get if I put your code, but can soomebody please tell me what the exact code I need to write in my method for sending the email to the given email id on click of a button.

Please write a code here with the Import Statements.

Regards,

Nikesh Shah

christiansche
Active Participant
0 Kudos

Hi,

have a look at this [blog|http://wiki.sdn.sap.com/wiki/display/WDJava/Sendmailwithattachmentusingwebdynpro+API%27s].

Or have a look at this [thread|;.

Best Regards,

Christian

Former Member
0 Kudos

Hi, I have written following code but getting this error now:

exception: Sending failed; nested exception is: javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550 5.7.1 Unable to relay for 'email id'

Please tell me what''s wrong in this code: or if the code is right then what settings needs to be check from SMTP side?

try

{

IWDClientUser clientuser= WDClientUser.getCurrentUser();

IUser user1=clientuser.getSAPUser();

String email=user1.getEmail();

wdComponentAPI.getMessageManager().reportSuccess("Email id of Logged user : "email);

String host = "prnetwtsv006.hosting.primusnetworks.com"; //specify the host ip here

String to = email;

Properties props = System.getProperties();

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

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

MimeMessage message = new MimeMessage(session);

if(to!=null)

{

try{

message.setRecipient(javax.mail.Message.RecipientType.TO,new InternetAddress(to));

javax.mail.Transport.send(message);

wdComponentAPI.getMessageManager().reportSuccess("Mail sent to: " + to);

}catch (Exception e){

wdComponentAPI.getMessageManager().reportException("exception: " + e.getMessage(),false);

}

}

} catch (WDUMException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

Former Member
0 Kudos

Hi,

Check if this method works by hardcoding some valid email id in the "to" string,

Also verify if a valid email id is set in the portal UME for the specific user.

Regards,

Manjunath

Former Member
0 Kudos

Hi Manjunath,

I have tried with the new email id but still getting the same error. Any other settings that I need to do in Visual Admin for SMTP ?

Regards,

Nikesh Shah

p330068
Active Contributor
0 Kudos

Hi Nilesh,

Please check the UME under system adminstrator>System Configuration in portal. SMTP information(IP) mentioned or not.

SMTP details should be there for mailing applications.

Thanks

Arun Jaiswal

Former Member
0 Kudos

HI All,

Now I am getting below exception :

Sending failed; nested exception is: javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 504 5.5.2 <musatst>: Helo command rejected: need fully-qualified hostname

My Server name is "musatst", and in SMTP they just allow FQDN. Now how do I change this hostname to FQDN ?

junwu
Active Contributor
0 Kudos

i think you have to authenticate first.

if you are in CE

http://help.sap.com/saphelp_nwce711core/helpdata/en/45/89caf2152f09b5e10000000a114a6b/frameset.htm

FOR NW7

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/2e/c00e408230c442e10000000a1550b0/frameset.htm

A GOOD EXAMPLE

/people/bojidar.kadrev/blog/2006/11/27/enabling-java-mail-functionality-in-your-applications