如何使用java和JACOB从Outlook进行休息,即用户发送或取消邮件

时间:2016-08-02 18:56:18

标签: java jacob

我正在使用JACOB打开并通过Outlook显示电子邮件。代码工作正常,当我按下一个按钮时,打开outlook“发送邮件窗口”附带的文字。我的问题是我希望得到用户按发送或取消按钮的回复。

这是代码:

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();
//            }

        }

0 个答案:

没有答案