user1175338
user1175338

Reputation: 79

System.Runtime.InteropServices.COMException: "Error in IMAPIFormMgr.LoadForm: MAPI_E_NOT_FOUND"

I'm developing an addin application for Outlook using Redemption. I'm trying to get a list of addresses to add to the email as addresses and then show the email.

session = new RDOSession();
session.Logon();
var contacts = session.GetDefaultFolder
     (rdoDefaultFolders.olFolderContacts);
 var mailItem = contacts.Items.Add("New message");
 AddinModule.CurrentInstance.Session.MAPIOBJECT = mailItem.Session.MAPIOBJECT;
 mailItem.Attachments.Add(file, OlAttachmentType.olByValue, Type.Missing, Type.Missing);
 RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderContacts);

 foreach (RDOFolder subFolder in folder.Folders)
 {
     if (subFolder.Name == "CAS_Notifications")
     {
         foreach (var rdoItem in subFolder.Items)
         {
             RDOContactItem contactItem = rdoItem as RDOContactItem;
             RDODistListItem distList = rdoItem as RDODistListItem;
             if (distList != null)
             {
                 foreach (RDOAddressEntry rdoAddressEntry in distList.OneOffMembers)
                 {
                     mailItem.Recipients.Add(rdoAddressEntry.SMTPAddress);
                 }
             }
             else if (contactItem != null)
             {
                 mailItem.Recipients.Add(contactItem.Email1Address);
             }
         }
     }
 }
 mailItem.Display();

Threw exception

System.Runtime.InteropServices.COMException: "Error in IMAPIFormMgr.LoadForm: MAPI_E_NOT_FOUND"

How to debug it?

Upvotes: 0

Views: 307

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66215

The following line is the problem:

var mailItem = contacts.Items.Add("New message");

Add takes either a message class (e.g. "IPM.Note" or one of the olItemType / rdoItemType enums (such as olMailItem = 0).

The error you get essentially tells you that MAPI cannot find a form for the specified message class ("New message").

Upvotes: 1

Related Questions