Hi Team,
Am trying to send a email using localSMTP pro. I have verified the following link
http://www.tutorialspoint.com/java/java_sending_email.htm
This is my code
public void sendmail() throws MessagingException {
String to = new String();
to = to;
String from = new String();
from = from;
String host = "localhost";
Properties prop = System.getProperties();
prop.setProperty("mail.smtp.host", host);
Session session = Session.getDefaultInstance(prop);
try{
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from)); // Illegal Address String
message.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(subj);
message.setText(txt);
Transport.send(message);
}
catch(MessagingException mex){
mex.printStackTrace();
}
}
This is the error message which i got
javax.mail.internet.AddressException: Illegal address in string ``''
at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:108)
at view.Mail.sendmail(Mail.java:67)
at view.Mail.Send(Mail.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Can any one pls help me?
Regards,
Prasad K T.