java - 启动 MS Outlook,并在电子邮件中添加附件

标签 java email outlook

在我的申请中,要求发送带有附件的电子邮件。

只是打开带有附件的新邮件的 Outlook。 剩下的取决于用户是否发送:)

我使用下面的代码。

try {
String stLineSep; // String containing the system line separator
// Line separator:
stLineSep = System.getProperty("line.separator"); // Get it

Runtime.getRuntime().exec(
new String[] {"rundll32",
"url.dll,FileProtocolHandler",
"mailto:" + "&attachment=" + "c:\\ashish.txt"}
);//","attachment;filename="+strFileName
}
catch (Exception ex) {
ex.printStackTrace();
}

我可以在没有附件的情况下打开 Outlook,您能告诉我如何在有附件的情况下使用 Outlook。请帮忙 提前致谢

最佳答案

mailto: 不需要处理该问题(http://abauchu.net/blog/post/2008/12/28/Handling-mailto-url-and-attachment-with-Gmail-from-the-desktop 找到的 mailto URL 方案 [RFC 2368])。一种解决方案是更直接地调用 Outlook,但这会导致非常紧密的耦合: http://www.grauberger.org/wordpress/2013/07/18/e-mail-mit-anhang-ueber-die-cmd-in-outlook-oeffnen/ (语言是德语)它只是使用 Outlook 客户端可执行文件的固定路径...

"C:\Program Files\Microsoft Office\Office14\Outlook.exe" /m "test@example.org?subject=WhateverSubjectYouWish&body=seeAttachmentOrWhatever" /a "C:\myAttachment.txt"

关于java - 启动 MS Outlook,并在电子邮件中添加附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25301077/

相关文章:

email - Cakephp:电子邮件错误 SSL

python - 使用 Python 对多部分电子邮件进行 PGP 签名

excel - 有人有解决方法来解决使用 Outlook 插件保存和发送的错误吗?

java - URLImageSource 在 Java 10 中失败,但在 Java 8 中失败

java - CTCI Making Anagrams - 得到不正确的输出

java - Spring Security 4.指定访问决策管理器时出现异常

java - 简单日期格式验证

email - A/B 测试电子邮件 - 添加另一个 utm- 变量

c# - 如何将多个收件人添加到 mailitem.cc 字段 c#

c# - 通过 C# 应用程序创建 Outlook 电子邮件草稿