繁体   English   中英

将附件邮件添加到Outlook

[英]Add attachment mailto Outlook

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

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界面来发送邮件。

代码执行的结果。

谢谢你的帮助。

使用固定路径访问Outlook客户端可执行文件进行尝试。

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+"\"");
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM