wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes Hide All recipients email address 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 "Hide All recipients email address" Watch "Hide All recipients email address" New topic

Hide All recipients email address

varun bihani
Ranch Hand

Joined: Aug 11, 2003
Posts: 96
I am able to send html format mail using javamail.
but I want to send mail to multiple users at the same time.
so i have stored email addresses in an array but i dont want to display all the email addresses on the TO field in the recipients mail box. I only want to that the reciepient see that the mail has been sent to him only..
My code goes something like this..
String to=request.getParameter("to");
String from=request.getParameter("from");
String subject=request.getParameter("subject");
String body=request.getParameter("body");
String mailHost="";
boolean sent = false;
Properties props = new Properties();
props.setProperty("mail.smtp.host", mailHost);
Session ssn = Session.getDefaultInstance(props);
Message msg = new MimeMessage(ssn);
int i=0;
StringTokenizer st = new StringTokenizer(to,",");
String[] totalrec=new String[10];
while (st.hasMoreTokens())
totalrec[i]= st.nextToken();
InternetAddress fromAdd = new InternetAddress(from);
InternetAddress[] toAdd = new InternetAddress[i];
for (int j = 0; j < i; j++)
toAdd[j] = new InternetAddress(totalrec[j]);
msg.setRecipients(Message.RecipientType.TO, toAdd);
msg.setContent(body, "text/html");
sent = true;

}catch(Exception e)

<a href="http://www.galaxyweblinks.com" target="_blank" rel="nofollow">www.galaxyweblinks.com</a><br /><a href="http://www.freechatcode.com" target="_blank" rel="nofollow">www.freechatcode.com</a><br /><a href="http://www.onlinefamilytreemaker.com" target="_blank" rel="nofollow">www.onlinefamilytreemaker.com</a>
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Perhaps you want to send the message to yourself and then BCC (blind carbon copy) each recipient. Take a look at the Message class and the Message.RecipientType class documentations.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link: http://aspose.com/file-tools
subject: Hide All recipients email address