Solved

mail program not compiling

Posted on 2006-11-09
3
279 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 500 total points
ID: 17909854
ru sure you are running the changed class?
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb stateless example 2 20
java example issue 3 22
Bot application - advice 3 38
learn programming 8 34
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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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 …

840 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