HowTo: Get root folder in outlook

Add-in Express™ Support Service
That's what is more important than anything else

HowTo: Get root folder in outlook
Torsten Lang

Posts: 3
Joined: 2006-11-08
After studying your examples of your Outlook Developer Tricks I always noticed that you entered the name of the inbox's parent folder hardcoded.
Since the "Personal Folders"-folder of every computer might be called differently I am wondering if there is a way to get the name dynamically.

We plan to add a new folder being a sibling of the inbox-, contacts, outbox-, etc folder, but to do so we need the name of the root folder.
Usually it would be "Personal Folders", but my Outlook for example has no "Personal Folders" due to the localization, it is called differently ("Postfach - [forename lastname]").

I managed to get the whole folder structure, but this doesn't really help me as my "Personal Folders" has a folder as sibling on the same level called "public folders", aswell there might be more folders on the same level.

I have been searching for hours to get the folder object that holds my inbox as child (with poor success) and I'd pretty much appreciate any help.
Posted 10 Nov, 2006 09:18:29 Top
Dmitry Kostochko

Add-in Express team

Posts: 2875
Joined: 2004-04-05
Hi Torsten,

You can try to use the code below:

  function GetFullFolderName(const AFolder: MAPIFolder): WideString;
    IDisp: IDispatch;
    Folder: MAPIFolder;
    Result := '';
      Folder := AFolder;
      while Assigned(Folder) do begin
        Result := '' + Folder.Name + Result;
        IDisp := Folder.Parent;
        if Assigned(IDisp) then
          IDisp.QueryInterface(IID_MAPIFolder, Folder)
          Folder := nil;
      if Result 
 '' then Delete(Result, 1, 1);
      // mailbox permissions

  S: WideString;
  IInbox: MAPIFolder;
  IInbox := OutlookApp.GetNamespace('MAPI').GetDefaultFolder(olFolderInbox);
  if Assigned(IInbox) then
      S := GetFullFolderName(IInbox);
      IInbox := nil;

P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.

Posted 10 Nov, 2006 11:36:59 Top
Torsten Lang

Posts: 3
Joined: 2006-11-08
Working like a charm,

thank you :)
Posted 13 Nov, 2006 04:00:24 Top