[英]Using javax.mail to send to multiple recipients
I've got the following... 我有以下......
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
Which works fine but when I attempt to add this multiple times (with different variables for to
) it only sends to the last statement. 其工作正常,但是当我尝试这个多次添加(具有不同的变量to
)只发送到最后一条语句。 I've also attempted sending something like email1@gmail.com :email2@gmail.com
as the to
variable but this throws back an error. 我还尝试发送类似email1@gmail.com :email2@gmail.com
作为to
可变的,但,这将引发回一个错误。
Does anyone have any suggestions as to how I'd send mail to multiple recipients using JUST one e-mail and not multiple e-mails using javax.mail
? 有没有人对如何使用javax.mail
使用JUST一封电子邮件而不是多封电子邮件向多个收件人发送邮件有任何建议?
msg.setRecipients()
将地址数组作为第二个参数。
Use Message's subclass - MimeMessage. 使用Message的子类 - MimeMessage。 It implments the setRecipients(Message.RecipientType type, Address[] addresses)
method. 它包含setRecipients(Message.RecipientType type, Address[] addresses)
方法。
Furthermore, you could choose which specific message you need to use: IMAPMessage, POP3Message, SMTPMessage
. 此外,您可以选择需要使用的特定邮件: IMAPMessage, POP3Message, SMTPMessage
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.