[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

mail program not compiling

Posted on 2006-11-09
3
Medium Priority
?
326 Views
Last Modified: 2010-03-31
i want to send a  mail;but i am getting execption

 
setRecipients(javax.mail.Message.RecipientType,javax.mail.Address[]) in javax.mai
l.Message cannot be applied to (javax.mail.Message.RecipientType,javax.mail.inte
rnet.InternetAddress[],boolean)
    [javac]             msg.setRecipients(javax.mail.Message.RecipientType.TO, j
avax.mail.internet.InternetAddress.parse("sfsf@sff.com"), false
);


mail code
*******

Properties props = new Properties();
            props.put( "mail.transport.protocol","mail.transport.protocol");
            props.put( "mail.smtp.host","mail.smtp.host");

            javax.mail.Session session = Session.getDefaultInstance(props, null);


      
            // Construct a MimeMessage
      
            javax.mail.Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress("webmaster@sffsf.com","from")) ;
            msg.setRecipients(javax.mail.Message.RecipientType.TO, javax.mail.internet.InternetAddress.parse("sfsf@sff.com"), false);

            // -- set a CC: or BCC:
            /*String cc  = (String) mail.get("cc");
            String bcc = (String) mail.get("bcc");*/
            String cc = "ry@ryry.com";
            String bcc = "ry@ryt.com";
            if (cc != null &&  (!cc.trim().equals("")))  msg.setRecipients(Message.RecipientType.CC,  InternetAddress.parse(cc,  false));
            if (bcc != null && (!bcc.trim().equals(""))) msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(bcc, false));

            msg.setSubject("Hi");
            msg.setSentDate(new Date());
            msg.setText("ryryry");

            // Send the message.
            Transport.send(msg);
0
Comment
Question by:chaitu chaitu
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 17905602
>  msg.setRecipients(javax.mail.Message.RecipientType.TO, javax.mail.internet.InternetAddress.parse("sfsf@sff.com"), false);

should b:

 msg.setRecipients(javax.mail.Message.RecipientType.TO, javax.mail.internet.InternetAddress.parse("sfsf@sff.com", false));
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 17905847
if i give my smtp host its still connecting to "mail.smtp.host",


            props.put( "mail.transport.protocol","mail.transport.protocol");
            props.put( "mail.smtp.host","mail.xxxx.com");                   // i have given my smtp host

            javax.mail.Session session = Session.getDefaultInstance(props, null);


  [java] DEBUG SMTP: trying to connect to host "mail.smtp.host", port 25
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 17909854
ru sure you are running the changed class?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question