on 05-16-2008 3:23 PM
I wrote the followring method:
public void sendMail( ) {
//@@begin sendMail()
String host =" "; // Specify the host
// Get the From Address
String from = wdContext.currentContextElement().getFromAddress();
// Get the To Address
String to = wdContext.currentContextElement().getToAddress();
// Initialize Session
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
* Session session = Session.getDefaultInstance(props, null);*
// Create new MimeMessage
* MimeMessage message = new MimeMessage(session);*
try {
// Set the From Address
* message.setFrom(new InternetAddress(from));*
// Set the To Address
message.addRecipient(message.RecipientType.TO,
new InternetAddress(to));
// Set the Subject
message.setSubject("Test Mail");
// Set the Text
message.setText(wdContext.currentContextElement().getTextMessage());
// Send message
Transport.send(message);
messageMgr.reportSuccess("Mail Sent Successfully");
} catch (AddressException e) {
messageMgr.reportException(e.toString(),false);
} catch (MessagingException e) {
messageMgr.reportException(e.toString(),false);
}
//@@end
}
The problem is that it complains on: Session, MimeMessage, InternetAddress, AddressException and MessagingException. Why is it doing that Should I have done something before?
Dear Hoda,
Did u add external jars files to project: smtp.jar, activation.jar and mail.jar.
Regards,
Vaibhav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello again 😃
I have updated my business card profile.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I tried to download that file ut it is not working?
Regards,
Hoda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
Where can I find the smtp.jar file?`
Regards,
Hoda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have implemented acicator.jar and mail.jar but it is still complaining.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I said earlier, please add 3 jar files, viz., smtp.jar, activation.jar, mail.jar
Please use below mentioned code:
String strMailDetail[] = new String[10];
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 am following the blog by Giridharan S from SAP Labs India, and I have some problems with:
-message.addRecipient(message.RecipientType.TO,
It is complaining on RecipientType
-Transport.send(message);
It is complaining on the method send()
-messageMgr.reportSuccess("Mail Sent Successfully");
It is complaining on the method messageMgr, I tried to write transport. before but it is still not working.
Help me please!
Regards,
Hoda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use
Message message = new MimeMessage(session);
instead of
MimeMessage message = new MimeMessage(session);
It works for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.