gpt4 book ai didi

java - 将附件邮件添加到 Outlook

转载 作者:行者123 更新时间:2023-12-01 09:58:06 25 4
gpt4 key购买 nike

我想从我的应用程序发送一封包含以下代码的电子邮件:

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

Result of the execution of the code.

感谢您的帮助。

最佳答案

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

关于java - 将附件邮件添加到 Outlook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37027002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com