ActiveXComponent axOutlook = new ActiveXComponent("Outlook.Application");
Dispatch mailItem = Dispatch.call(axOutlook, "CreateItem", 0).getDispatch();
Dispatch inspector = Dispatch.get(mailItem, "GetInspector").getDispatch();
Dispatch recipients = Dispatch.call(mailItem, "Recipients").getDispatch();
Dispatch.call(recipients, "Add", "12738022@qq.com");
Dispatch.put(mailItem, "Subject", "ceshi");
String body = "ccccc";
Dispatch.put(mailItem, "HTMLBody", "<div>" + body + "</div>");
//这个代码的意思是,是否弹窗outlook的窗口,如果不希望出现,直接注释代码就行
// Dispatch.call(mailItem, "Display");
Dispatch.call(mailItem, "Send");
System.gc();
java-jacob发送邮件
最新推荐文章于 2024-08-16 23:08:28 发布