Link to home
Start Free TrialLog in
Avatar of chaitu chaitu
chaitu chaituFlag for India

asked on

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
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);
Avatar of Mick Barry
Mick Barry
Flag of Australia image

>  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));
Avatar of chaitu chaitu

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial