Send Mail to multiple Recipients in java

后端 未结 12 757
孤城傲影
孤城傲影 2020-12-02 08:23

I want to send a message to multiple Recipients using following the method :

message.addRecipient(Message.RecipientType.TO, String arg1);

<

12条回答
  •  余生分开走
    2020-12-02 08:50

    String[] mailAddressTo = new String[3];    
    mailAddressTo[0] = emailId_1;    
    mailAddressTo[1] = emailId_2;    
    mailAddressTo[2] = "xyz@gmail.com";
    
    InternetAddress[] mailAddress_TO = new InternetAddress[mailAddressTo.length];
    
    for (int i = 0; i < mailAddressTo.length; i++)
    {
        mailAddress_TO[i] = new InternetAddress(mailAddressTo[i]);
    }
    
    message.addRecipients(Message.RecipientType.TO, mailAddress_TO);ress_TO = new InternetAddress[mailAddressTo.length]; 
    

提交回复
热议问题