如何在客户端机器上使用 javaScript 打开 Outlook? [英] How to open outlook using javaScript on client machine?

查看:54
本文介绍了如何在客户端机器上使用 javaScript 打开 Outlook?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在服务器中打开 Outlook 的 Java 代码.但我想在客户端机器上打开 Outlook 并用 HTML 内容填充正文.是否可以使用 javaScript、VbScript 或任何其他技术.

I Have java code which open outlook in server . but i want to opent outlook on client machine and fill Body with HTML content . is it possible using javaScript , VbScript or any other Technology .

          public static void main(String[] args) {
//  System.setProperty("java.library.path", "/path/to/library");

    Display display = Display.getCurrent();
    Shell shell = new Shell(display);
    OleFrame frame = new OleFrame(shell, SWT.NONE);
    // This should start outlook if it is not running yet
    OleClientSite site = new OleClientSite(frame, SWT.NONE, "OVCtl.OVCtl");
    site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    // now get the outlook application
    OleClientSite site2 = new OleClientSite(frame, SWT.NONE,
        "Outlook.Application");
    OleAutomation outlook = new OleAutomation(site2);
    // 
    OleAutomation mail = invoke(outlook, "CreateItem", 0 /* Mail item */)
        .getAutomation();
    setProperty(mail, "To", "testTo@gmail.com"); /*
                           * Empty but could also be
                           * predefined
                           */
    setProperty(mail, "Bcc", "testBcc@gmail.com"); /*
                           * Empty but could also be
                           * predefined
                           */
    setProperty(mail, "Cc", "testCc@gmail.com"); /*
     * Empty but could also be
     * predefined
     */
    setProperty(mail, "BodyFormat", 2 /* HTML */);
    setProperty(mail, "Subject", "Top News for you");
    setProperty(mail, "HtmlBody",
        "<html>Hello<p>, please find some infos here.</html>");
    File file = new File("d:/vicky.txt");
    if (file.exists()) {
      OleAutomation attachments = getProperty(mail, "Attachments");
      invoke(attachments, "Add", "d:/vicky.txt");
    } else {
      MessageDialog
          .openInformation(shell, "Info",
              "Attachment File c:/temp/test.txt not found; will send email with attachment");
    }
    invoke(mail, "Display" /* or "Send" */);

    }

推荐答案

HTML - Javascript: Simple mailto in html a 标签,见下面是简单的标记.

HTML - Javascript: Simple mailto in html a tag, see below for the simple markup.

点击这里邮寄

点击后,它将打开 Outlook.(其实会打开默认的邮件客户端)

Once clicked, it will open Outlook. (Actually it will open the default mail client)

Java:

示例代码:打开 Outlook 并添加附件.

Sample code: open Outlook and add an attachment.

new ProcessBuilder("C:\\Program Files\\Microsoft Office\\Office14\\OUTLOOK.exe","/a","C:\\Desktop\\stackoverflow.txt").start();

第一个参数 = Outlook 的路径.

First Argument = path to Outlook.

第二个参数 = Outlook 附件命令.

Second Argument = Outlook attachment command.

第三个参数 = 附件路径.

Third Argument = Attachment path.

这篇关于如何在客户端机器上使用 javaScript 打开 Outlook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆