在我的申请中,要求发送带有附件的电子邮件。
只是打开带有附件的新邮件的 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/