aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Java Mail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Mail" Watch "Java Mail" New topic
Author

Java Mail

L.John
Greenhorn

Joined: Aug 29, 2001
Posts: 24
Hi to All,
I am using Java Mail API, and for testing purpose, i am giving my own email id for sender and receiver both
I am ruuning a Daemon which actually gets a batch of lets say 20 records from the database and for each record an email has to be send to someone(In this case Receiver is me ). The first email i get is fine , the second one and subsequent emails i get , lets say, the daemon extracted the 5th record, so when i am sent an email for the fifth record . I have the following:

From:LJohn To:LJohn;LJohn;LJohn;LJohn;LJohn;
Sub:You have got mail Cc:

Now I would like to know can i get rid of this problem of Recepient.Type (i.e my name being repeted the number of times equal to the number of records going to be fetched from the database).
It would be kind of you to let me know , how can i avoid my name to be appended or added to the existing one .
My code is as follows:
-------------------------
props = new Properties();
props.put(protocol,host);
s = Session.getInstance(props);
message = new MimeMessage(s);
InternetAddress from =new InternetAddress(SEND_MAIL_FROM_ADMIN);
message.setFrom(from);
InternetAddress to = new InternetAddress(email_id);// a string .
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject(subject);
String matter = "Hello ! This is checking the working of the Java Mail API for Request ID:" + requestid;
message.setText(matter);
Transport.send(message);
Thanks ,

Kind Regards,
John

Yogen Vadnere
Ranch Hand

Joined: Sep 20, 2001
Posts: 58
why dont u use for all address except first emailId
Message.RecipientType.BCC


Yogen Vadnere
L.John
Greenhorn

Joined: Aug 29, 2001
Posts: 24
Hi Yogen,
Thanks for replying to my query.
I am not really clear about what you suggested to me. Here the Recepient Type I have is TO.
It would be kind of you to tell me more about what you meant by it .
Thanks,
Regards,
John
why dont u use for all address except first emailId
Message.RecipientType.BCC
Tom Ben
Ranch Hand

Joined: Aug 17, 2001
Posts: 109
Look like here
InternetAddress to = new InternetAddress(email_id);// a string
message.addRecipient(Message.RecipientType.TO, to);

If email_id is just a string with a new email address each time for each different document this you do not need the (InternetAddress to = new InternetAddress(email_id)
Just update the email_id with the new email address or this case just yours once and say (message.addRecipient(Message.RecipientType.TO, email_id)
the object "to" is being casted up to an Address array. So maybe that is why you are getting your email address over and over again. I do not use InternetAddress unless I am sending more than one person an email.
------------------
Sun Certified Programmer on the Java 2 Platform


Sun Certified Programmer on the Java 2 Platform
Tom Ben
Ranch Hand

Joined: Aug 17, 2001
Posts: 109
Look like here
InternetAddress to = new InternetAddress(email_id);// a string
message.addRecipient(Message.RecipientType.TO, to);

If email_id is just a string with a new email address each time for each different document this you do not need the (InternetAddress to = new InternetAddress(email_id)
Just update the email_id with the new email address or this case just yours once and say (message.addRecipient(Message.RecipientType.TO, email_id)
the object "to" is being casted up to an Address array. So maybe that is why you are getting your email address over and over again. I do not use InternetAddress unless I am sending more than one person an email.
------------------
Sun Certified Programmer on the Java 2 Platform
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java Mail