Desenvolvimento F?cil
Guest
|
After creating a new .pst file only 2 folders are created by default with the new Outlook.Store(.pst).
Example 1:
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:
When I was debugging the code 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. And also recommended by Add-in express in this article https://www.add-in-express.com/creating-addins-blog/2014/01/09/outlook-special-folders/
Soo this is the right way.
When this method is executed, depending on the parameter, it creates the folder in Outlook.Store. I created a simple COM Addin to exemplify:
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:
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?
I created an example Addin:
apoio.facil.com.br/files/docsite/MyAddin11.zip
PS.:
1 - Sorry about my bad english;
2 - This is killing me; |
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
Hello,
Why is the Outlook.Store.GetDefaultFolder method creating folders?
It doesn't. I suggest that you turn all other COM add-ins off.
Your English is perfectly okay with me.
Andrei Smolin
Add-in Express Team Leader |
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
Forgot to mention: your add-in doesn't create those folders. So, some other add-in should be involved. Or, there's a VBA macro run at some point.
Andrei Smolin
Add-in Express Team Leader |
|
Desenvolvimento F?cil
Guest
|
Hi Andrei, Thank you by your answer.
I've removed all addins in my Outlook except my example COM add-in. And the unique code that are in that COM add-in is creating folders. All code are in the Startup event.
To simulate yout can download my example COM add-in:
http://apoio.facil.com.br/files/docsite/myaddin11.zip
1 - Open MS Outlook
2 - File
3 - Account Settings -> Data Files -> Add
I created a new .pst file with no account associated.
By default, Outlook creates only 2 folders.
Than you can close the Outlook and open again(Just to fire the Startup method of my example com addin).
Than you can check the folders of this new Store |
|
Andrei Smolin
Add-in Express team
Posts: 18791
Joined: 2006-05-11
|
Hello,
I can't reproduce the issue using your add-in.
Before you start Outlook for the second time, make sure you have no OUTLOOK.EXE running in processes.
Andrei Smolin
Add-in Express Team Leader |
|