on 05-19-2008 12:26 PM
Hi folks,
I am triggering an email using web dynpro UI where my hostName is serverXX.com and portNo XXX .
When i tried using default port no, then gives me error like
Could not connect to SMTP host: serverXX, port: 25;
Then i used
Properties property = new Properties();
property.put("mail.smtp.port","XXX");
This does not gives any error but processing enter into an infinite loop that never ends.Then i have to close the window. If above port is other than our used port then again it gives above told error (Port 25).
Thanks in anticipation,
Mandeep Virk
lease use below mentioned code:
String strMailDetail[] = new String10;
StringBuffer strMailBody;
try
{
strMailBody = new StringBuffer();
Properties props;
Session session;
Provider p;
String strSMTPIPAddress = // Enter SMTP Server address here
java.util.Date todayDate = new java.util.Date();
// Get System Properties
props = System.getProperties();
// Setup SMTP Mail Server
props.put("mail.smtp.host", strSMTPIPAddress);
// Get session without Authenticator
session = Session.getDefaultInstance(props, null);
p = session.getProvider("smtp");
Message message = new MimeMessage(session);
message.setFrom("email_ID");
message.addRecipient(Message.RecipientType.TO, "email_ID");
message.addRecipient(Message.RecipientType.CC, "email_ID");
MimeBodyPart mbp = new MimeBodyPart();
mbp.setText(strMailBody.toString());
Multipart mt = new MimeMultipart();
message.setContent(mt);
message.setSentDate(new java.util.Date());
/*****************************/
//Send message
Transport.send(message);
/*****************************/
}
catch (Exception e)
{
wdComponentAPI.getMessageManager().reportException(e+" in Send Mail method", false);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
i got the same problem then i did this hope it will work for u also.
i did it for gmail.
Properties props = new Properties();
String host = "smtp.gmail.com";
String port = "465";
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", port);
props.put("mail.smtp.socketFactory.port", port);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
Regards
Trilochan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi trilochan,
Thanks
Now i am able to send email properly.
In my syntax i used a code snippet to validate user input for mail recipient's.
if(email instanceof String){
String[] result = email.split("@");
if(result.length == 2){
return true;
} }
Now i want to enter multiple recipient's for mail but this time it gives error used for above validation "Invalid email"(user defined).
For multiple recipient's i wrote a code
message.setRecipients( javax.mail.Message.RecipientType.TO, InternetAddress.parse(
wdContext.currentEmailDataElement().getToAddress(), false));
Any Idea
Mandeep Virk
Hi.
There is a complete list of properties on this page:
http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html
You need to authenticate explicitly with Transport.connect.
Try this example listed on the same page:
Transport tr = session.getTransport("smtp");
tr.connect(smtphost, username, password);
msg.saveChanges(); // don't forget this
tr.sendMessage(msg, msg.getAllRecipients());
tr.close();
Regards, Mikael
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.