• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hide All recipients email address

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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="";
//out.println(subject);
boolean sent = false;
Properties props = new Properties();
props.setProperty("mail.smtp.host", mailHost);
Session ssn = Session.getDefaultInstance(props);
ssn.setDebug(true);
Message msg = new MimeMessage(ssn);
int i=0;
try{
StringTokenizer st = new StringTokenizer(to,",");
String[] totalrec=new String[10];
while (st.hasMoreTokens())
{
totalrec[i]= st.nextToken();
out.println("recepients"+i+":"+totalrec[i]);
i++;
}
InternetAddress fromAdd = new InternetAddress(from);
msg.setFrom(fromAdd);
msg.setSubject(subject);
InternetAddress[] toAdd = new InternetAddress[i];
for (int j = 0; j < i; j++)
{
toAdd[j] = new InternetAddress(totalrec[j]);
System.out.println("Rec"+j+":"+toAdd[j]);
}
msg.setRecipients(Message.RecipientType.TO, toAdd);
msg.setContent(body, "text/html");
Transport.send(msg);
sent = true;

System.out.println("FROM2:"+fromAdd+"\n\n");
}catch(Exception e)
{
out.println("Error:\n\n"+e);
}
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic