我想使用以下方法将消息发送给多个收件人::
message.addRecipient(Message.RecipientType.TO, String arg1);
要么
message.setRecipients(Message.RecipientType.TO,String arg1);
但有一个困惑是,在第二个论证中,如何传递多个地址,如:
message.addRecipient(Message.RecipientType.CC, "abc@abc.com,abc@def.com,ghi@abc.com");
要么
message.addRecipient(Message.RecipientType.CC, "abc@abc.com;abc@def.com;ghi@abc.com");
我也可以使用替代方法发送消息,但想知道上述方法的用途。如果我不能使用它(直到现在我还没有得到任何回答以上要求),那么这种方法需要在邮件API中。
发布于 2018-03-23 16:44:00
每一个这个代码工作对我来说,请尝试与此发送邮件给多个recepients
private String recipient = "yamabs@gmail.com ,priya@gmail.com ";
String[] recipientList = recipient.split(",");
InternetAddress[] recipientAddress = new InternetAddress[recipientList.length];
int counter = 0;
for (String recipient : recipientList) {
recipientAddress[counter] = new InternetAddress(recipient.trim());
counter++;
}
message.setRecipients(Message.RecipientType.TO, recipientAddress);
https://stackoverflow.com/questions/-100007763
复制相似问题