?
Solved

mail program not compiling

Posted on 2006-11-09
3
Medium Priority
?
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

718 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