Solved

mail program not compiling

Posted on 2006-11-09
3
252 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now