I'm using JACOB to open and display email via Outlook. The code is working fine and when i press a button it open outlook "send mail window" with the attachment and text. My problem is i want to get response from outlook that user press send or cancel button.
Here is code:
public OutlookJACOB() {
mapi[0] = "MAPI";
email[0] = 0;
ol = new ActiveXComponent("Outlook.Application");
outlook = ol.getObject();
Dispatch.call(outlook, "GetNamespace", mapi).toDispatch();
}
public void createEmail(Map<String, Object> params) {
Dispatch mail = Dispatch.call(outlook, "CreateItem", email).toDispatch();
Dispatch.put(mail, "Subject", params.get("subject"));
Dispatch.put(mail, "Body", params.get("body"));
String to[] = (String[]) params.get("to");
String attachments[] = (String[]) params.get("attachments");
if (to != null) {
if (to.length > 0) {
String _to = "";
for (Object t : to) {
_to += t + ";";
}
Dispatch.put(mail, "To", _to);
}
}
if (attachments != null) {
if (attachments.length > 0) {
Dispatch attachs = Dispatch.get(mail, "Attachments").toDispatch();
for (Object attachment : attachments) {
Dispatch.call(attachs, "Add", attachment);
}
}
}
Dispatch.call(mail, "Display");
System.out.println("vareient is : "+v);
// while (true) {
// Dispatch.get(this.ol, "Quit");
// this.ol.safeRelease();
// }
}