Commit 6a863320 authored by 曲欣红's avatar 曲欣红

q

parent f1a209ca
......@@ -22,6 +22,7 @@ import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import com.egolm.common.exception.PluginException;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeUtility;
public class MailUtil {
......@@ -71,8 +72,15 @@ public class MailUtil {
MimeBodyPart mbpFile = new MimeBodyPart();
FileDataSource fileDataSource = new FileDataSource(file);
mbpFile.setDataHandler(new DataHandler(fileDataSource));
String filename= new String(fileDataSource.getName().getBytes(),"ISO-8859-1");
mbpFile.setFileName(filename);
String filename = fileDataSource.getName();
String name = filename.substring(0, filename.lastIndexOf("."));
String exname = filename.substring(filename.lastIndexOf("."));
String encodeName = MimeUtility.encodeText(name) + exname;
mbpFile.setFileName(encodeName);
m.addBodyPart(mbpFile);
}
}
......@@ -81,4 +89,17 @@ public class MailUtil {
throw new PluginException(e);
}
}
public static void main(String[] args) throws Exception {
// EmailSender sender = new EmailSender();
// File[] files = new File[]{new File("C:/opt/modules/dev/boot/file/excel/40001-收银员资料维护-20180813.xlsx"), new File("C:/opt/modules/dev/boot/file/2018-08-15/admin_客单价对比图表.html"), new File("C:/opt/modules/dev/boot/file/2018-08-15/admin_销售对比图表.html")};
// MailMessage mailMessage = new MailMessage("测试");
// mailMessage.setFiles(files);
// sender.send(mailMessage, "13384825689@163.com");
//String json = "{\"password\": \"hong804334\",\"port\": 25,\"protocol\": \"smtp\",\"smtpAuth\": \"true\",\"smtpHost\": \"smtp.163.com\",\"sslEnable\": \"false\",\"username\": \"13384825689@163.com\"}";
File[] files = new File[]{new File("C:/opt/modules/dev/boot/file/excel/40001-收银员资料维护-20180813.xlsx"), new File("C:/opt/modules/dev/boot/file/2018-08-15/admin_客单价对比图表.html"), new File("C:/opt/modules/dev/boot/file/2018-08-15/admin_销售对比图表.html")};
MailUtil.sendMail("smtp.163.com", 25, true, "13384825689@163.com", "hong804334", "测试aaa", "测hi", files, "13384825689@163.com");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment