0

After creating a new .pst file only 2 folders are created with the new Outlook.Store(.pst).

Example 1:

New .pst

After you close Outlook and reopen it, several folders are created. Some are standard folders, such as Recycle Bin, RSSFeed, and more. But some are strange and have strange names (with strange characters).

Example 2:

New Folders

When I was debugging the routine of my COM Addin I have identified that in Addin's 'Startup' event, there is a code that checks the default folders of the Outlook.Store.

The 'GetDefaultFolder' method of the Outlook.Store object is used. This method is recommended by Microsoft to identify the default folders of an Outlook.Store.

When this method is executed, depending on the parameter, it creates the folder in Outlook.Store. I created a simple COM Addin to exemplify:

In the Startup event I did this:

        private StringBuilder sb = new StringBuilder("##Log##");

        //Startup
        Outlook.NameSpace ns = OutlookApp.Session;
        Outlook.Store lastStore = ns.Stores[1];//Just to get the new Store

        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderCalendar);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderConflicts);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderContacts);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderDeletedItems);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderDrafts);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderInbox);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderJournal);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderJunk);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderLocalFailures);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderManagedEmail);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderNotes);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderOutbox);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderRssFeeds);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderSentMail);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderServerFailures);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderSuggestedContacts);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderSyncIssues);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderTasks);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olFolderToDo);
        GetDefaultFolder(lastStore, Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);

        System.Diagnostics.Debug.Write(sb.ToString());

        private void GetDefaultFolder(Outlook.Store newStore, Outlook.OlDefaultFolders olFolderKind)
    {
        Outlook.MAPIFolder rootFolder = null;

        rootFolder = newStore.GetRootFolder();
        sb.AppendLine($"qtd: {rootFolder.Folders.Count}");

        try
        {
            sb.AppendLine($"Folder kind: {olFolderKind.ToString()}");
            newStore.GetDefaultFolder(olFolderKind);
        }
        catch
        {
        }
        finally
        {
            sb.AppendLine($"qtd: {rootFolder.Folders.Count}");
            sb.AppendLine();
            sb.AppendLine();
            
            if (rootFolder != null)
                Marshal.ReleaseComObject(rootFolder);
        }
    }

I load the new .pst file (Outlook.Store) and fetch all default folders. But in a few cases new Folders are added.

The log of this code is:

Log

Ex

qtd: 1 Folder kind: olFolderCalendar qtd: 2

qtd: 2 Folder kind: olFolderConflicts qtd: 2

qtd: 2 Folder kind: olFolderContacts qtd: 3

qtd: 3 Folder kind: olFolderDeletedItems qtd: 3

qtd: 3 Folder kind: olFolderDrafts qtd: 4

qtd: 4 Folder kind: olFolderInbox qtd: 4

qtd: 4 Folder kind: olFolderJournal qtd: 5

qtd: 5 Folder kind: olFolderJunk qtd: 6

qtd: 6 Folder kind: olFolderLocalFailures qtd: 6

qtd: 6 Folder kind: olFolderManagedEmail qtd: 6

qtd: 6 Folder kind: olFolderNotes qtd: 7

qtd: 7 Folder kind: olFolderOutbox qtd: 8

qtd: 8 Folder kind: olFolderRssFeeds qtd: 9

qtd: 9 Folder kind: olFolderSentMail qtd: 9

qtd: 9 Folder kind: olFolderServerFailures qtd: 9

qtd: 9 Folder kind: olFolderSuggestedContacts qtd: 9

qtd: 9 Folder kind: olFolderSyncIssues qtd: 9

qtd: 9 Folder kind: olFolderTasks qtd: 10

qtd: 10 Folder kind: olFolderToDo qtd: 10

qtd: 10 Folder kind: olPublicFoldersAllPublicFolders qtd: 10

Questions

What is this strange folder created by Outlook? Why is the Outlook.Store.GetDefaultFolder method creating folders? Is there another method that can be used that returns the same information as the GetDefaultFolder but DOES NOT create folders?

Community
  • 1
  • 1
Anderson Rissardi
  • 2,377
  • 1
  • 16
  • 21

1 Answers1

1

The GetDefaultFolder method of the Store or Namespace class doesn't and shouldn't create folders in Outlook.

First of all, I see a custom add-ins running in Outlook (DocSite). Before creating any test with OOM I'd suggest to disable all of them.

Also I see an interesting domain name configured in Outlook. Is it IMAP or Exchange profile? If so, I'd suggest configuring any SMTP mail box instead.

Is a custom store provider?

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • 1
    Have you find the cause? Is it a custom store provider or other add-ins? – Eugene Astafiev May 09 '17 at 13:10
  • Hi Eugene, I'm developing Docsite Addin using Addin Express. Yes, it's DocSite that creates folders, I created another addin just to simulate the incident. In fact, it is the 'Store.GetDefaultFolder' method that creates strange folders. 1 account is Exchange and the other is SMTP / POP. The new .pst file is not connected with ay account, I just created. Do you think it's best to create a post in the Addin Express forum? Sorry about my bad english. – Anderson Rissardi May 09 '17 at 13:14
  • To create the 'Example' store I just did: File -> Account Settings -> Data Files -> Add. Than only 2 folders was created(Outlook default). In my addin, in the startup event I have some code that check the default folders of every store. When this method is executed, on startup, for my new Store, some kinds of Folders occurs an exeption and a Strage folders is created. I have no idea why this happend. – Anderson Rissardi May 09 '17 at 13:19
  • Try to create a simple SMTP account in Outlook without any add-ins registered and running in Outlook. Are you able to reproduce the issue in that case? – Eugene Astafiev May 09 '17 at 16:47
  • I did some tests like you said and the answer is no. It does not happen. Just happens when a new Outlook.Store(new .pst file) was created with no e-mail account associated. – Anderson Rissardi May 09 '17 at 17:14
  • Did you try to add a new store programmatically in your tests? – Eugene Astafiev May 09 '17 at 17:55
  • No, I didn't. I'll try this now – Anderson Rissardi May 10 '17 at 11:43
  • I did and this situation still happens. – Anderson Rissardi May 10 '17 at 12:26
  • Have you disabled all add-ins before adding a new store? – Eugene Astafiev May 10 '17 at 12:31
  • I'm using the MS Office 13, with the MSOffice 16 It doesnt happens. – Anderson Rissardi May 10 '17 at 12:31
  • Yes, the only addin that I use is my example Addin, to simulate this situation. It's and Add-in Express com addin. You can download here: [link](apoio.facil.com.br/files/docsite/myaddin11.zip) – Anderson Rissardi May 10 '17 at 12:36
  • What code do you use for creating a store? Have you tried contacting ADX developers? – Eugene Astafiev May 10 '17 at 12:53
  • To create the Store I used https://www.add-in-express.com/creating-addins-blog/2013/05/31/outlook-accounts-stores-folders-items/ this example from ADX. - Outlook.Namespace.AddStoreEx – Anderson Rissardi May 10 '17 at 13:06
  • Yes, I create this topic on ADX Forum: https://www.add-in-express.com/forum/read.php?FID=5&TID=14523&MID=74404#message74404 – Anderson Rissardi May 10 '17 at 13:06