• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending email : Error Type Expected & Wrong number of arguments  RSS feed

 
Lijoy John
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to All,
I am having a class where I am using Java Mail API and have got
a method .
There are 2 scenario:
1) When I am giving the following statements just after the
default construcor:
//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.jcom.net");
// create some properties and get the default Session
Session s = Session.getInstance(props);
// create a message
MimeMessage message = new MimeMessage(s);
//------------------------------------------------
I get the following Error on compilation:
./resdaemon/StatusSendEmail.java:38: Type expected.
props.put("mail.smtp.host", "smtp.jcom.net");
^
1 error
2) The second scenario When i give the same above statements in
a method (Here the above 'type expected' error is not shown
then) :
/**
* if the status code is success
*
*/
public void emailToRequester(StatusDetails sd){
try {
props.put("mail.smtp.host", "smtp.jcom.net");
// create some properties and get the default Session
Session s = Session.getInstance(props);
// create a message
MimeMessage message = new MimeMessage(s);
// set the from and to address
InternetAddress from = new InternetAddres
("sendersid@mail.com");
message.setFrom(from);
InternetAddress to = new InternetAddress("sd.getEmailID()");
message.addRecipient(Message.RecipientType.TO, to);
Now if i do this i am getting the following error:
./resdaemon/StatusSendEmail.java:55: Wrong number of arguments in method.
Session s = Session.getInstance(props);
Here the argument seems to be fine as i checked the API .
Kindly let me know what could possible be done to get rid of this error.
All responses will be appreciated.
Thanks,
Regards,
John
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!