I am using Com4J to interact with Microsoft Outlook. I have generated the Java type definitions as per the Com4J tutorial. Here is an example of some code that waits for the user to close an email.
// Registers my event handler
mailItem.advise(
ItemEvents.class,
new ItemEvents() {
@Override
public void close(Holder<Boolean> cancel) {
// TODO Auto-generated method stub
super.close(cancel);
System.out.println("Closed");
}
}
);
// Displays the email to the user
mailItem.display();
This code successfully displays the email to the user. Unfortunately, my program never prints "Closed"
when the user closes the window.