使用JavaMail,我将执行以下类似操作,以将replayTo发送给更多一封电子邮件。
我尝试创建一个数组并将地址添加到该数组。我不能只添加列表,因为setReplyTo需要一个字符串
message.setReplyTo( listOfAddresses)
我有以下内容:
String[] mailAddressTo = new String[3];
String abb = user.getStoreAbbreviation();
mailAddressTo[0] = abb + "[email protected]" + ",";
mailAddressTo[1] = abb + "[email protected]" + ",";
mailAddressTo[2] = abb + "[email protected]";
InternetAddress[] mailAddress_TO = new InternetAddress[mailAddressTo.length];
for (int i = 0; i < mailAddressTo.length; i++) {
mailAddress_TO[i] = new InternetAddress(mailAddressTo[i]);
}
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true);
// this line worked fine to use the replyTo message.setReplyTo(new InternetAddress("[email protected]"));
//same list worked fine for the seTo message.setTo(mailAddressTo);
试试这个
message.setReplyTo(new InternetAddress[]
{new InternetAddress(mailAddressTo)});
我怎样才能通过名单?
有什么帮助吗?
最佳答案
看起来这是MimeMessageHelper的限制。尝试:
message.getMimeMessage().setReplyTo(mailAddress_TO);