将附件邮件添加到Outlook [英] Add attachment mailto Outlook

查看:106
本文介绍了将附件邮件添加到Outlook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过以下代码从我的应用程序发送电子邮件:

I want to send an email from my application with the following code:

public static void mailto(String subject,String path) throws IOException, URISyntaxException {
   String uriStr = String.format("cmd.exe /c start mailto:%s?subject=%s&attachment=%s",
            "test@test.fr",
            urlEncode(subject),
            urlEncode(path));
    Runtime.getRuntime().exec(uriStr);
}

private static final String urlEncode(String str) {
    try {
        return URLEncoder.encode(str, "UTF-8").replace("+", "%20");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}

窗口正常打开,除了附件之外,其他所有东西都可以正常工作.我尝试了多种方法将附件添加到电子邮件中,但是没有找到解决方法.我必须通过Outlook界面来发送邮件.

The window opens normally, everything works except the attachment.I tried many method to add an attachment to the email, however I did not find solution. It is imperative that I go through the Outlook interface for sent mail.

代码执行的结果.

感谢您的帮助.

推荐答案

尝试使用Outlook客户端可执行文件的固定路径进行尝试.

Try it out with a fixed path to your Outlook client executable.

public static void mailto(String subject,String path) throws IOException {   
  Runtime.getRuntime().exec("C:\\Program Files (x86)\\Microsoft Office\\Office12\\outlook.exe /c ipm.note /m \"test@test.fr&subject="+subject+"\" /a \""+path+"\"");
}

这篇关于将附件邮件添加到Outlook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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