按照本指南,我至少找到了一种处理前景的方法:Vogella,Eclipse-Microsoft Integration
基本上我使用 OleClientSite 类来调用 Outlook。然后我使用 oleAutomation 类来发送邮件。
代码片段:
Shell shell = new Shell(Display.getDefault());
OleFrame frame = new OleFrame(shell, SWT.NONE);
// This should start outlook if it is not running yet
OleClientSite site = new OleClientSite(frame, SWT.NONE, "OVCtl.OVCtl");
site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
// Now get the outlook application
OleClientSite site2 = new OleClientSite(frame, SWT.NONE,
"Outlook.Application");
OleAutomation outlook = new OleAutomation(site2);
//
OleAutomation mail = invoke(outlook, "CreateItem", 0 /* Mail item */)
.getAutomation();
setProperty(mail, "To", "aav@gmail.com"); /*
* Empty but could also be
* predefined
*/
setProperty(mail, "Bcc", "test@gmail.com"); /*
* Empty but could also be
* predefined
*/
setProperty(mail, "BodyFormat", 2 /* HTML */);
setProperty(mail, "Subject", "Top News for you");
setProperty(mail, "HtmlBody",
"<html>Hello<p>, please find some infos here.</html>");
invoke(mail, "Send" /* or "Send" */);