【问题标题】:Cannot save the attachment. The operation failed. An object cannot be found error in server无法保存附件。操作失败。在服务器中找不到对象错误
【发布时间】:2019-07-04 09:50:49
【问题描述】:

我正在尝试保存 Outlook 邮件的附件,当它有数据时我可以保存附件。但对于空附件,它会抛出Cannot save the attachment. The operation failed. An object cannot be found 的异常。 在我的本地我可以保存,但这个问题出现在服务器中。

void saveattachments(Outlook.Attachment attachment) { string currentTime = DateTime.Now.ToString("hh_MM_ss"); try { attachment.SaveAsFile(GetConfigSettings("attachmentPath") + "\\attachment_" + "_" + currentTime + "_" + attachment.FileName); } catch(exception e) {} }

为什么它在服务器中为空白文件引发错误,但在本地却没有。

【问题讨论】:

    标签: c# outlook attachment


    【解决方案1】:

    Microsoft 目前不推荐也不支持任何无人值守、非交互式客户端应用程序或组件(包括 ASP、ASP.NET、DCOM 和 NT 服务)的 Microsoft Office 应用程序自动化,因为 Office 可能表现出不稳定Office 在此环境中运行时出现的行为和/或死锁。

    如果您要构建在服务器端上下文中运行的解决方案,您应该尝试使用已确保无人值守执行安全的组件。或者,您应该尝试找到允许至少部分代码在客户端运行的替代方案。如果您使用服务器端解决方案中的 Office 应用程序,该应用程序将缺少许多成功运行所需的功能。此外,您将承担整体解决方案稳定性的风险。在Considerations for server-side Automation of Office 文章中了解更多信息。

    您可以考虑改用 MAPI(Outlook 所基于的低级 API)。

    【讨论】:

      猜你喜欢
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      • 2012-10-08
      • 2015-03-29
      • 1970-01-01
      • 2018-02-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多