0

Starting from Outlook 2013 and newer, Outlook may sometimes (in case of .OST files) append "(This computer only)" suffix to folder names. In other cases (.PST files) this does not happen. So, depending on particular circumstances a folder name can be "Some folder" or "Some folder (This computer only)" or "Some folder (who knows what else)" for localized versions of Outlook.

Is there any way to get the folder name without this suffix (so that I'd always get, let's say, "Some folder" regardless of whether this suffix is present in the folder name or not? Currently I don't see any property in Outlook.Folder object which would return me that short name.

I can think of a workaround like getting the default Contacts folder name, checking if it ends with "(something)" and then stripping "(something)" off folder names but it does not seem an elegant solution for me.

Another approach could be creating a temp folder and checking if its name is different from the one I provided. If they are different, that difference is the suffix. However, creating/deleting a folder just for that doesn't look elegant either.

In MFCMapi tool, I also can't find "Contacts" anywhere in the MAPI properties of the folder named "Contacts (This computer only)" so it doesn't seem to be just Outlook OOM limitation.

It it true that there is no way to get the folder name without that suffix programmatically and I should rely on my (ugly) workarounds only?

Alex
  • 2,469
  • 3
  • 28
  • 61

1 Answers1

0

Do not rely on the folder names. Besides having the "(This computer only)" suffix for the IMAP4 stores, the names can be localized.

Always use Namespace.GetDefaultFolder and Store.GetDefaultFolder.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • I know how to get the default folder (actually, I mention this in my question - "...getting the default Contacts folder name, checking if it ends with ..."). I need this for any folder including user-created folders (they also have this suffix). – Alex Aug 30 '18 at 14:39
  • "I need this" - I mean "I need suffix detection and removal". – Alex Aug 30 '18 at 14:46
  • You can just recursively loop through all folders starting with the top level folder, but I still don't understand why the folders names are important. – Dmitry Streblechenko Aug 30 '18 at 16:15
  • My software syncs Outlook folders with another storage. If I have a folder, let's say, "Orders", I must create "Orders" folder in that storage. But if the folder is "Orders (This computer only)", I must still create "Orders", not "Orders (This computer only)". – Alex Aug 31 '18 at 07:12