on 04-15-2008 10:46 AM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
problem has been solved!!!!!!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanksv a lot Jhansi!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!!!!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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:
[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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.