if(!StringUtil.isEmpty(message_type_to)){
if (message_type_to.contains(",")) {
String[] split = message_type_to.split(",");
InternetAddress[] adr = new InternetAddress[split.length];
for (int i = 0; i < split.length; i++) {
adr[i] = new InternetAddress(split[i]);
}
message.setRecipients(Message.RecipientType.TO, adr);
}else {
// 指明邮件的收件人
message.setRecipient(Message.RecipientType.TO, new InternetAddress(message_type_to));
}
}
//多个抄送人
if (!StringUtil.isEmpty(message_type_cc)) {
if (message_type_cc.contains(",")) {
String[] splits = message_type_cc.split(",");
// // 构建一个群发地址数组
InternetAddress[] adr = new InternetAddress[splits.length];
for (int i = 0; i < splits.length; i++) {
adr[i] = new InternetAddress(splits[i]);
}
// Message的setRecipients方法支持群发。。注意:setRecipients方法是复数和点 到点不一样
message.setRecipients(Message.RecipientType.CC, adr);
} else {
// 指明邮件的抄送人
message.setRecipient(Message.RecipientType.CC, new InternetAddress(message_type_cc));
}
}