Email multiple recipients without revealing other recipients

前端 未结 8 1934
庸人自扰
庸人自扰 2020-12-24 08:20

I\'m using javamail to send emails to a list of recipients, but don\'t want them to be able to see who else received the email. I also don\'t want to send it using BCC sinc

8条回答
  •  甜味超标
    2020-12-24 08:23

    Actually, we don't have to manually create InternetAddress objects for Multi Recepients. InternetAddress api provides a parse() method to do this for us. Sample code for this is as below,

    msg.setRecipients(Message.RecipientType.TO,  InternetAddress.parse(toAddress));
    

    Here parse method creates multiple InternetAddress objects if toAddress contains multiple email addresses seperated by ,(comma).

    Check for below API for more details.

    http://docs.oracle.com/javaee/6/api/javax/mail/internet/InternetAddress.html#parse(java.lang.String)

    Happy Coding. :)

提交回复
热议问题