My application sends Emails with jacob. Now I want to just open the Mail in some cases and wait for the user to press send (or he closes the mail)
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
I've tried it with an while(true) loop
while (true) {
if (Dispatch.get(mail, "Sent").getBoolean()) {
return;
}
}
But with this approch i get an exception (after I've sent the mail):
com.jacob.com.ComFailException: Invoke of: Sent
Source: Microsoft Outlook
Description: the element was moved or deleted.