我找到了一種方法來處理至少前景,該指南如下:Vogella, Eclipse-Microsoft Integration
基本上我用OleClientSite類調用前景。然後我使用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", "[email protected]"); /*
* Empty but could also be
* predefined
*/
setProperty(mail, "Bcc", "[email protected]"); /*
* 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" */);
沒有API,它與每一個郵件客戶端的工作,所以最好的選擇是使用[Java郵件API(http://www.mkyong.com/java/javamail -api-sending-email-via-gmail-smtp-example /)並直接發送郵件。 – nif
我已經在用Java郵件API玩了,我的主要問題是我不知道哪個郵件服務器將在客戶機上運行。我爲以下屬性使用了什麼值:mail.smtp.host。我知道客戶端將在包含郵件服務器的本地網絡中,但我不知道它的「名稱」。 – Markus