【发布时间】:2017-10-06 06:46:13
【问题描述】:
我正在尝试将当前电子邮件保存在 Outlook 中。使用功能区按钮访问代码。当我对 MailItem 执行 SaveAs 方法时,我总是得到 0x80004004 (E_ABORT) 异常。
这是我的代码:
Outlook._Application outlook = new Outlook.Application();
if (outlook.ActiveExplorer().Selection.Count > 0)
{
Object selectedObject = outlook.ActiveExplorer().Selection[1];
if (selectedObject is Outlook.MailItem)
{
Outlook._MailItem mailItem = (selectedObject as Outlook._MailItem);
Helpers.CheckDir(userAppPath + @"temp");
try
{
mailItem.SaveAs(userAppPath + @"temp\tempmail.msg", Outlook.OlSaveAsType.olMSGUnicode);
doUpload = true;
}
catch (Exception ex)
{
doUpload = false;
}
}
}
如果我使用完全相同的文件名从 Outlook 手动将其保存在同一位置,我可以将其重新加载到我的代码中,但我无法使用 SaveAs 方法将相同的电子邮件保存在代码中。
我尝试了各种 OlSaveAsType 类型。还有 MailItem 类型而不是 _MailItem 类型。
有什么想法吗?
【问题讨论】:
-
你能读懂 mailitem 的任何属性吗?
-
是的。我可以访问很多。
-
您在 SaveAs 方法中尝试过 Outlook.OlSaveAsType.olMSG 吗?
-
谢谢。是的,我也试过那个。没有运气。
-
传递给
SaveAs方法的实际文件路径字符串是什么?是本地文件夹吗?
标签: email outlook outlook-addin mailitem