• Post Reply Bookmark Topic Watch Topic
  • New Topic

"import package"  RSS feed

 
abi lash
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
Iam doing project in Java Mail System,i have forwarded my program,please check it and tell the answer for it...

\\\"i dont no the path to add the mail.jar file for this,please tell me.....\\\"

Program give below


import java.lang.Exception.*;
import javax.mail.*;//error here
import javax.mail.internet.*;//error here

public class Abhi1 {

public static void main(String[] args) throws Exception {
String host = "smtp.mydomain.com";
String from = "me@myweb.com";
String to = "you@myweb.com ";
Properties prop = System.getProperties();
prop.put("mail.smtp.host",host);
Session sess1 = Session.getDefaultInstance(prop,null);
Mimemessage msg = new MimeMessage(sess1);
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.To,new InternetAddress(to));
msg.setText("you won the lotri");
Transport.send(msg);



}

}
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Well, do you have mail.jar? If not, you can download it here. You may also want to check out our J2EE FAQ, which links to some resources that are useful for learning JavaMail.

You also need to remove the line "import java.lang.Exception.*;" (or change it to "import java.lang.Exception;"), because Exception is not a package, but a class.
[ December 30, 2006: Message edited by: Ulf Dittmer ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!