在我的项目中,我想提取附加在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...
}