0
我的應用程序發送電子郵件與雅各。 現在我只想在某些情況下,打開郵件並等待用戶按發送(或他關閉了郵件)等待郵件不發送/關閉與雅各
ActiveXComponent axcOutlook = new ActiveXComponent("Outlook.Application");
Dispatch mail = Dispatch.invoke(axcOutlook.getObject(), "CreateItem", Dispatch.Get, new Object[] { "0" }, new int[0]).toDispatch();
...
Dispatch.put(mail, "Subject", subject);
Dispatch.put(mail, "Body", sbBody.toString());
Dispatch.put(mail, "ReadReceiptRequested", "false");
Dispatch.call(mail, "Display");
//And here I want to wait till the Mail is sent/closed
我已經有一段時間(true)循環
while (true) {
if (Dispatch.get(mail, "Sent").getBoolean()) {
return;
}
}
試了一下
但是這個計算策略我得到一個異常(我已經發送後的郵件):
com.jacob.com.ComFailException: Invoke of: Sent
Source: Microsoft Outlook
Description: the element was moved or deleted.
不錯。 'Send'event正在工作。但我無法驗證郵件是否已關閉。我確實收到了「關閉」事件,但它出現在「你想保存......」之前。如果您在Outlook中選擇取消,則即使Mail仍處於打開狀態,該事件也會被解除。你有什麼想法如何解決這個問題? – griFlo
好的。我沒有找到解決我的近距離問題的答案。所以在我爲此浪費更多時間之前,如果關閉事件被觸發,我只需關閉該項目而不手動。 – griFlo