我的应用程序使用jacob发送电子邮件。 现在我想在某些情况下打开邮件并等待用户按发送(或者他关闭邮件)
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
我尝试了一段时间(真实)循环
while (true) {
if (Dispatch.get(mail, "Sent").getBoolean()) {
return;
}
}
但是有了这个approch我得到一个例外(在我发送邮件之后):
com.jacob.com.ComFailException: Invoke of: Sent
Source: Microsoft Outlook
Description: the element was moved or deleted.