I am working with Outlook Nicknames
using Redemption for a C# .NET Framework console application. When I attempt to add a PST store with:
RDOPstStore pstStore = rdoSession.Stores.AddPSTStore(@"c:\Support\nicknames.pst", 1, "Test Store");
I receive the error:
Error in IMsgServiceAdmin::AdminProviders: MAPI_E_INTERFACE_NOT_SUPPORTED
Here is the relevant code:
using System;
using Outlook = Microsoft.Office.Interop.Outlook;
using Redemption;
RDOSession rdoSession = new RDOSession();
rdoSession.MAPIOBJECT = new Outlook.Application().Session.MAPIOBJECT;
RDOStore defaultStore = rdoSession.Stores.DefaultStore;
RDOPstStore pstStore = rdoSession.Stores.AddPSTStore(@"c:\Support\nicknames.pst", 1, "Test Store");
RDONicknames defaultNicknames = rdoSession.GetNicknames();
RDONicknames pstNicknames = pstStore.GetNicknames();
pstNicknames.Clear();
foreach (RDONickName nickname in defaultNicknames)
{
pstNicknames.Add(nickname.GetAddressEntry());
}
pstNicknames.Save();
foreach (RDONickName nickname in pstNicknames)
{
Console.WriteLine(nickname.Name + "_" + nickname.SMTPAddress);
}
Console.ReadLine();
I experimented with the Catastrophic Failure trying to AddPstStore solution, however this did not apply to my situation.
All suggestions and assistance welcome.
You end up using IMAPISession
from the outlook.exe process, and MAPI cannot handle marshaling IMsgServiceAdmin
interface across process boundaries.
You can either
rdoSession.MAPIOBJECT
property, call rdoSession.Logon
:rdoSession.Logon(new Outlook.Application().Session.CurrentProfileName);
You can also call Logon
with no parameters to log to the default profile.
rdoSession
inside the outlook.exe process space. This has an extra benefit of letting the bitness of your process be different from that of Outlook:var app = new Outlook.Application();
RDOSession rdoSession = app.CreateObject("Redemption.RDOSession");
rdoSession.MAPIOBJECT = app.Session.MAPIOBJECT;