1

I am getting error as Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) in outlook. I have debugged the code and found exception in Outlook.Items.Add() method. The code is like this,

Outlook.NameSpace nSpace = null;
Outlook.MAPIFolder InBoxFolder = null;

Outlook._Application OutlookApp = new Outlook.Application();
nSpace = OutlookApp.GetNamespace("MAPI");
InBoxFolder = nSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items FolderItems = InBoxFolder.Folders.GetFirst().Items;
Outlook.MailItem mail = (Outlook.MailItem)FolderItems.Add(Outlook.OlItemType.olMailItem);

Please help me with this. Thanks in advance.

Kewal
  • 59
  • 7
  • Is there something unusual about the first sub folder of the Inbox? Also, why are you trying to create an email in that folder? If you just want to create an email to send, use Application.CreateItem. – Eric Legault Oct 08 '14 at 15:05
  • I have mail stored in a database and I want to sync those mails with outlook. Thats why I am creating mail and adding to the folder by setting properties. Is there any other way to sync. – Kewal Oct 10 '14 at 04:40
  • Is this an add-in or an out-of-process .exe? If the former, you may be getting the exception because of the Object Model Guard. You don't need to create a new instance of the Application object and you must inherit all instances of that object from the one passed to the AddInInitialize method. – Eric Legault Oct 20 '14 at 14:17

0 Answers0