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" , "cccc@qq.com");
//邮件主题
Dispatch.put(mailItem, "Subject", "xxxxxxxx");
Dispatch.put(mailItem, "CC", "xxxx@qq.com;xxxxxx@qq.com");
Dispatch attachments = (Dispatch) Dispatch.call(mailItem, "Attachments").getDispatch();
Dispatch.call(attachments, "Add" , fileUrl);
//字符串另外一种方式
//StringBuffer sb = new StringBuffer();
//sb.append("<h1>Hi guys, <br>Please book your TRS for this week:</h1>");
String body = "<html><body><div style='color:red;'>xxxxxxxx</div></body></html>";
Dispatch.put(mailItem, "HTMLBody", body);
Dispatch.call(mailItem, "Display");
java-使用jacob拉起outlook创建新邮件
最新推荐文章于 2024-08-03 21:02:21 发布