chaitu chaitu
asked on
mail program not compiling
i want to send a mail;but i am getting execption
setRecipients(javax.mail.M essage.Rec ipientType ,javax.mai l.Address[ ]) in javax.mai
l.Message cannot be applied to (javax.mail.Message.Recipi entType,ja vax.mail.i nte
rnet.InternetAddress[],boo lean)
[javac] msg.setRecipients(javax.ma il.Message .Recipient Type.TO, j
avax.mail.internet.Interne tAddress.p arse("sfsf @sff.com") , false
);
mail code
*******
Properties props = new Properties();
props.put( "mail.transport.protocol", "mail.tran sport.prot ocol");
props.put( "mail.smtp.host","mail.smt p.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.ma il.Message .Recipient Type.TO, javax.mail.internet.Intern etAddress. parse("sfs f@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. RecipientT ype.CC, InternetAddress.parse(cc, false));
if (bcc != null && (!bcc.trim().equals(""))) msg.setRecipients(Message. RecipientT ype.BCC, InternetAddress.parse(bcc, false));
msg.setSubject("Hi");
msg.setSentDate(new Date());
msg.setText("ryryry");
// Send the message.
Transport.send(msg);
setRecipients(javax.mail.M
l.Message cannot be applied to (javax.mail.Message.Recipi
rnet.InternetAddress[],boo
[javac] msg.setRecipients(javax.ma
avax.mail.internet.Interne
);
mail code
*******
Properties props = new Properties();
props.put( "mail.transport.protocol",
props.put( "mail.smtp.host","mail.smt
javax.mail.Session session = Session.getDefaultInstance
// Construct a MimeMessage
javax.mail.Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("webmaster
msg.setRecipients(javax.ma
// -- 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.
if (bcc != null && (!bcc.trim().equals(""))) msg.setRecipients(Message.
msg.setSubject("Hi");
msg.setSentDate(new Date());
msg.setText("ryryry");
// Send the message.
Transport.send(msg);
ASKER
if i give my smtp host its still connecting to "mail.smtp.host",
props.put( "mail.transport.protocol", "mail.tran sport.prot ocol");
props.put( "mail.smtp.host","mail.xxx x.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
props.put( "mail.transport.protocol",
props.put( "mail.smtp.host","mail.xxx
javax.mail.Session session = Session.getDefaultInstance
[java] DEBUG SMTP: trying to connect to host "mail.smtp.host", port 25
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
should b:
msg.setRecipients(javax.ma