In my project I want to extract the attachment that attached in a msg file. It works when I do testing on the development project, but once i put in the server I am getting this error "System.Runtime.InteropServices.COMException (0x80004004): Operation aborted".
Below is my code to extract the msg file.
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...
}
The error is on second line. Please help...
User contributions licensed under CC BY-SA 3.0