首页 > 解决方案 > System.Runtime.InteropServices.COMException (0x80004004):操作中止

问题描述

在我的项目中,我想提取附加在 msg 文件中的附件。它在我对开发项目进行测试时有效,但是一旦我放入服务器,我就会收到此错误“System.Runtime.InteropServices.COMException (0x80004004): Operation aborted”。

下面是我提取 msg 文件的代码。

 var outlook = new Microsoft.Office.Interop.Outlook.Application();
 MailItem item = (MailItem)outlook.CreateItemFromTemplate(file.fullPath, Type.Missing);

 for (int i = 1; i <= item.Attachments.Count; i++)
 {
      FileInfo fzip = null;
      if (Path.GetExtension(item.Attachments[i].FileName).ToLower().EndsWith(".zip"))
      {
           fzip = new FileInfo(SavePath + item.Attachments[i].FileName);
           string attpath = strSavePath + item.Attachments[i].FileName;
           item.Attachments[i].SaveAsFile(attpath);
           ..process zip...
       }

错误在第二行。请帮忙...

标签: c#outlook

解决方案


推荐阅读