0

I am trying to add pst store from outlook addin using Redemption with the code:

RdoSession = Redemption.RedemptionLoader.new_RDOSession();
RdoSession.MAPIOBJECT = (AddinModule.CurrentInstance as AddinModule).OutlookApp.Session.MAPIOBJECT;
string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\Outlook\mystore.pst";
RDOStores stores = RdoSession.Stores;
RDOStore store = stores.AddPSTStore(path, Outlook.OlStoreType.olStoreDefault, "test");

Line stores.AddPstStore throws System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure and it creates mystore.pst in correct location with the size of 265 KBs. New store/data file is not displayed in outlook and it does not apear in RdoSession.Stores on next execution. So my program tries to create it again (since it didint found it) and then same line crashes with:

System.InvalidCastException: Error in IMsgServiceAdmin::AdminProviders: MAPI_E_INTERFACE_NOT_SUPPORTED

Using office PIAs code works without any problems: https://msdn.microsoft.com/en-us/library/office/bb612380.aspx

I would keep redemption code since there is much more logic around it. I just moved these 5 lines to the begining of function to isolate the problem.

3

1 Answer 1

0

MAPI has a few marshaling bugs in the profile management interfaces (such as IMsgServiceAdmin).

Try to replace setting the RDOSession.MAPIOBJECT property with calling RDOSession.Logon.

Is you code running in a Outlook addin or a standalone app?

2
  • Thanks Dmitry. Its an add in. I refactored code to use outlook object model. I do rename store using RDOStore and it works without a problem. I noticed one more thing while playing around: RDOPstStore.PstPath also fails with similar error message. I will try using login instead of setting MAPI object in the morning just to see if it works. Should be few moments to check. Jun 23, 2015 at 21:18
  • If it is a COM addin, setting RDOSession.MAPIOBJECT should be fine as long as yoru code runs on the main thread. Profile interfaces do not like secondary threads. Jun 23, 2015 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.