none
refreshing store object before adding sub-folders RRS feed

  • Question

  • Hi all,

    I am trying to create an outlook add-in. In it I create a pst file and add it to the current session as a store with a custom name at application OnStartupComplete. Then, I try to add sub folders to that store.

    Problem is, as soon as the store is added if I try to add the sub folders, it gives an error and won't add the sub folders. However, when I run the method again by re-starting outlook it will add the folders properly, as the store is already created. It seems to me like a commit/refresh issue, but I am unsure (as I am a newbie to office dev). The error that is throws is:

    Error in IMAPIFolder.GetHierarchyTable: MAPI_E_INVALID_PARAMETER
    Component: Personal Folders

    this is when I call the following code on a newly added store/folder.

    (Redemption.RDOFolder).Folders.Add("folderName", System.Reflection.Missing.Value);

    I am using VS2010, C# and developing for Outlook 2003-2010.

    Any help/advice that you can give will be greatly appreciated.

    - Thimila


    Tuesday, December 4, 2012 8:39 AM

Answers

  • Thanks Ken for your response. And Eric for your interest to help me out. I greatly appreciate it.

    Eric, I was receiving the error on any store OR folder that would be just added.

    However, I figured out what was wrong with my code. The store/folder object needs to be released before its children can be manipulated. i.e.: the reference needs to be released (mostly using Marshal.ReleaseComObject) and retreived again (using EntryID or path) and then only sub folders added.

    -Thimila

    Wednesday, December 5, 2012 5:53 AM

All replies

  • Can you show the full code please?  It's unclear what folder you are adding a subfolder to.

    Eric Legault MVP (Outlook)
    About me...
    Try Outlook Appins - affordable and easy to use!

    Tuesday, December 4, 2012 3:42 PM
    Moderator
  • I would wait until later to add the store, like after the MAPILogonComplete() event fires. See if that makes a difference.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Thimila Fernando" <=?utf-8?B?VGhpbWlsYSBGZXJuYW5kbw==?=> wrote in message news:25211ace-5cd7-4b15-936c-9ebe0341c826...

    Hi all,

    I am trying to create an outlook add-in. In it I create a pst file and add it to the current session as a store with a custom name at application OnStartupComplete. Then, I try to add sub folders to that store.

    Problem is, as soon as the store is added if I try to add the sub folders, it gives an error and won't add the sub folders. However, when I run the method again by re-starting outlook it will add the folders properly, as the store is already created. It seems to me like a commit/refresh issue, but I am unsure (as I am a newbie to office dev). The error that is throws is:

    Error in IMAPIFolder.GetHierarchyTable: MAPI_E_INVALID_PARAMETER
    Component: Personal Folders

    this is when I call the following code on a newly added store/folder.

    (Redemption.RDOFolder).Folders.Add("folderName", System.Reflection.Missing.Value);

    I am using VS2010, C# and developing for Outlook 2003-2010.

    Any help/advice that you can give will be greatly appreciated.

    - Thimila



    Ken Slovak MVP - Outlook
    Tuesday, December 4, 2012 6:16 PM
    Moderator
  • Thanks Ken for your response. And Eric for your interest to help me out. I greatly appreciate it.

    Eric, I was receiving the error on any store OR folder that would be just added.

    However, I figured out what was wrong with my code. The store/folder object needs to be released before its children can be manipulated. i.e.: the reference needs to be released (mostly using Marshal.ReleaseComObject) and retreived again (using EntryID or path) and then only sub folders added.

    -Thimila

    Wednesday, December 5, 2012 5:53 AM