hi aamir,
i have done the same thing in my module.i think the code \below can help u.i have mad a class called mailer u can use the class.for using the class should download javamailapi,
java activationframework in ur class path and continiue. the code is
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class mailer{
public mailer(
String from,String to,String text1) {
boolean debug = true;
// create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", "ur smtp server ip address!!");
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
try {
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
InternetAddress[] address1 = {new InternetAddress();address1.parse("viky4u@yahoo.com,viky4u@yahoo.com")};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setRecipients(Message.RecipientType.BCC, address1);
msg.setSubject("Waltech Forum Message from "+ from );
msg.setSentDate(new Date());
msg.setText(text1);
// create and fill the first message part
//MimeBodyPart mbp1 = new MimeBodyPart();
//mbp1.setText(msgText1);
// create and fill the second message part
//MimeBodyPart mbp2 = new MimeBodyPart();
// Use setText(text, charset), to show it off !
//mbp2.setText(msgText2, "us-ascii");
// create the Multipart and its parts to it
Multipart mp = new MimeMultipart();
//mp.addBodyPart(mbp1);
//mp.addBodyPart(mbp2);
// add the Multipart to the message
//msg.setContent(mp);
// send the message
Transport.send(msg);
} catch (Exception mex) {
mex.printStackTrace();
Exception ex = null;
ex.printStackTrace();
}
}
}
reply back if u have any problem..this must work perfect.
bye,love
Vigneshk.c