"main" javax.mail.NoSuchProviderException: No Provider for Add type: rfc822
843830Jan 8 2003 — edited Jan 9 2003Hello,
I am new (very new) to JavaMail. I have been exploring a lot but I have not been successful in sending out my first java-based email yet!
I have downloaded the javamail-1_2.zip and jaf-1_0_2.zip
and have the mail.jar and activation.jar files in correct path. (As far as I can tell). However I could not get rid of this error.
I also extracted the files from these .jar files and put them in the class path.
Heres the error I am getting:
Exception in thread "main" javax.mail.NoSuchProviderException: No provider for Address type: rfc822
at javax.mail.Session.getTransport(Session.java:516)
at javax.mail.Transport.send0(Transport.java:155)
at javax.mail.Transport.send(Transport.java:81)
at SimpleSend.main(SimpleSend.java:26)
Heres my code:
import javax.mail.*;
import javax.mail.internet.*;
import java.util.Properties;
public class SimpleSend {
public static void main (String args[]) throws Exception {
String host = "mymailserver"; //I am putting the correct name here
String from = "me@mycompany.com"; // I am putting correct address here
String to = "me@mycompany.com"; // I am putting correct address here
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
Transport.send(message);
}
}
I saw the mention of:
javamail.charset.map
javamail.default.address.map
mailcap
Is this something I need to know? If so how do I use it?
Any help will be appreciated....
Any simple working sample will be a great help too!
-Chirag