问个邮件设计的小问题,在线等!!

loveshiwenhua 2010-10-21 08:22:59
主要指javaMail的一个方法javax.mail.internet.InternetAddress

当只有一个收件人地址为abcd@sina.com时,可以采用如下方式将收件人地址转换为InternetAddress[];

String toAddr = abcd@sina.com;

InternetAddress[] toList = {new InternetAddress(toAddr)};

如果有多个收件人该怎么办?如何将多个收件人的地址都转换为InternetAddress[]?

...全文
110 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
s0s0s0s 2010-10-21
  • 打赏
  • 举报
回复
InternetAddress[] toList =InternetAddress.parse("abcd@sina.com,abcd@sina.com,abcd@sina.com");
blazingfire 2010-10-21
  • 打赏
  • 举报
回复
String toAddr1 = abcd@sina.com;
String toAddr2 = abcd2@sina.com;

InternetAddress[] toList = {new InternetAddress(toAddr1), new InternetAddress(toAddr2)}
或用list再转化成数组:
List<InternetAddress> toList = new ArrayList<InternetAddress>();
toList.add(new InternetAddress(toAddr1));
toList.add(new InternetAddress(toAddr2));
InternetAddress[] toListArr = toList.toArray(new InternetAddress[toList.size()]);

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧