1

I want to add a folder to an existing folder in Outlook.

OApp = new();
Ons = OApp.GetNamespace("MAPI");
OMapiFld = Ons.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
OFriendsFld = OMapiFld.Folders["Friends"];
OFFolder = (Folder)OFriendsFld.Folders.Add("Jack", OlDefaultFolders.olFolderInbox);

If the Friends folder has other items already like

Friends - (1) Jan (2) Andrew

When I add a new Jack folder it appears like this

Friends (1) Jan (2) Jack (3) Andrew

The question I have is why is it always added as the second item in the sub folders.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
darbid
  • 2,545
  • 23
  • 55

1 Answers1

0

Outlook email folders are sorted alphabetically by default. In Outlook, click Folder and see if Show All Folders A to Z button is highlighted; if it is, all folders are sorted alphabetically. At this time, when you right-click any folder, the Sort subfolder A to Z option is not available.

Outlook folder sorting order

You may sort Outlook folders alphabetically by right-clicking the account or inbox folder and then select the sort subfolders A to Z options.

You can sort the folders in the Outlook UI programmatically by explicitly setting the PR_SORT_POSITION property on each subfolder. Read more about that in the Outlook VBA to Replicate 'Sort Subfolders A to Z' in the Folder Pane thread.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45