在我的项目中,我要提取附加在msg文件中的附件。当我在开发项目上进行测试时,它可以工作,但是一旦我将其放入服务器,就会收到此错误“ System.Runtime.InteropServices.COMException(0x80004004):操作中止”。
下面是我提取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...
}
错误在第二行。请帮助...