cancel
Showing results for 
Search instead for 
Did you mean: 

I am not able to execute the transport.send(message)

p330068
Active Contributor
0 Kudos

I am not able to execute the transport.send(message) when trying for sending mail. I am getting error like this : -

javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: 10.175.80.50, port: 25; nested exception is: java.net.ConnectException: Connection timed out: connect

Please help me on this to resolve this issue asap. thanks

Accepted Solutions (0)

Answers (8)

Answers (8)

p330068
Active Contributor
0 Kudos

Hi Vinod,

public void SendMail( )

{

//@@begin SendMail()

// Specify the host name of the mail server

String host ="----


";

IWDMessageManager messageMgr = wdControllerAPI.getComponent().getMessageManager();

// Initialize Session

Properties props = System.getProperties();

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

props.put("mail.smtp.auth", "true");

Authenticator auth = new Auth();

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

// Create new MimeMessage

MimeMessage message = new MimeMessage(session);

try

{

// Set the From Address

String from = wdContext.currentContextElement().getCtx_From();

message.setFrom(new InternetAddress(from));

// Set the To Address

String to = wdContext.currentContextElement().getCtx_To();

Address ar[] = new Address[1];

ar[0] = new InternetAddress(to);

message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

// Set the Subject

message.setSubject(wdContext.currentContextElement().getCtx_Subject());

// Set the Text

message.setText(wdContext.currentContextElement().getCtx_Text());

Transport tr = session.getTransport("smtp");

tr.connect("Put again here Host Name", Port Noumber, "userid", "password");

tr.sendMessage(message, ar);

}catch (AuthenticationFailedException e){

messageMgr.reportException(e.toString(),false);

}catch (AddressException e) {

messageMgr.reportException(e.toString(),false);

} catch (MessagingException e) {

messageMgr.reportException(e.toString(),false);

}catch (Exception e){

messageMgr.reportException(e.toString(),false);

}

//@@end

}

And also create the class Auth() like

public class Auth extends Authenticator {

public PasswordAuthentication getPasswordAuthentication()

{

String username = "userID";

String password = "Passwod";

return new PasswordAuthentication(username,password);

}

}

Please check it i think i will work. Also please use constant value for the to, from, subject and text.

p330068
Active Contributor
0 Kudos

problem has been solved!!!!!!!!

Former Member
0 Kudos

Hello arun,

I am also facing the same problem and i tried the ways that the forum described. If you got the idea please help me with an eg: code.

Regards

Vinod V

p330068
Active Contributor
0 Kudos

thanksv a lot Jhansi!!

p330068
Active Contributor
0 Kudos

there is some problem in fetching the parameter

?SapTest=mailto:arun?subject=test&body=Test

from the URL in Web Dynpro.

I wanted to fetch the "mailto:arun?subject=test&body=Test" from the URL.

WDProtocolAdapter.getProtocolAdapter().getRequestObject().getParameter("SapTest");

and WDWebContextAdapter.getWebContextAdapter().getRequestParameter("SapTest"); but not working.

Please advice!!!!!!

Former Member
0 Kudos

Hi Arun,

The problem might be with the string that you are giving. Try without giving any special characters. And I think you need to use Escape Sequences in order to get special characters within strings in Java.

Thanks n Regards,

Jhansi Miryala

p330068
Active Contributor
0 Kudos

Hi Jhansi and suresh,

thanks for th reply!!

I have both the thing but unable to fetch long string from the URL. small string it is ok.

Please advice how can i get long string also(100+ characters).

p330068
Active Contributor
0 Kudos

Hi Arun,

Thanks a lot for the response!

Now i am able to send the mail. By using link which you have provded without configuring doing in the server.

One more thing how can get the parameter from the running(calling and passing parameter to the web dynpro application ) URL in the web dynpro application to use the parameter?

Former Member
0 Kudos

Hi Arun,

One more thing how can get the parameter from the running(calling and passing parameter to the web dynpro application ) URL in the web dynpro application to use the parameter?

Use the following to get the parameter from URL.

IWDProtocolAdapter protocolAdapter = WDProtocolAdapter.getProtocolAdapter();

IWDRequest request = protocolAdapter.getRequestObject();

String paramValue = request.getParameter("key");

//if the url have a param ?name=abcd use

WDProtocolAdapter.getProtocolAdapter().getRequestObject().getParameter("name");

Refer to the help.sap.com.

http://help.sap.com/saphelp_nw04s/helpdata/en/44/be65751c743959e10000000a1553f6/frameset.htm

Thanks n Regards,

Jhansi Miryala

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Arun,

Pass the parameter like:

http://<server>:<port>/Application?EmpID=52

Get the parameter:

public void wdDoInit() {

String forumID = WDWebContextAdapter.getWebContextAdapter().getRequestParameter("EmpID");

}

Checkout these link also:

and

[Here|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/library/user-interface-technology/webdynpro/wd%20java/wdjava%20archive/inter-application-navigation%20in%20web%20dynpro.pdf]

Regards, Suresh KB

Former Member
0 Kudos
Former Member
0 Kudos

Hi Arun.

Solutions

The solution to your problem is to modify the mailTransferProtocol parameter in your JavaMail session. The session is configured within the WebSphere Application Server administrative console. If your value is "SMTP", it should be changed to "smtp".

Or else

The smtp server you use in your configs does not allow the server ip address to relay (send) emails. It could also be that the domain you use for your emails is not a mail domain for the ip you are sending from - thus rejected by the smtp relay check.

Or else

Restart your server and check it again

Check this link it will be helpfull:

Regards,

Arun.