mail program not compiling

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
    [javac]             msg.setRecipients(javax.mail.Message.RecipientType.TO, j
avax.mail.internet.InternetAddress.parse(""), false

mail code

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

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

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

            // -- set a CC: or BCC:
            /*String cc  = (String) mail.get("cc");
            String bcc = (String) mail.get("bcc");*/
            String cc = "";
            String bcc = "";
            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.setSentDate(new Date());

            // Send the message.
LVL 20
chaitu chaituAsked:
Who is Participating?
ru sure you are running the changed class?
>  msg.setRecipients(javax.mail.Message.RecipientType.TO, javax.mail.internet.InternetAddress.parse(""), false);

should b:

 msg.setRecipients(javax.mail.Message.RecipientType.TO, javax.mail.internet.InternetAddress.parse("", false));
chaitu chaituAuthor Commented:
if i give my smtp host its still connecting to "",

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

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

  [java] DEBUG SMTP: trying to connect to host "", port 25
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.