问题
I am developing an Outlook 2013 addin using c#. As part of the requirement I need to enumerate all the visible folders. Following is the sample code that I am using.
public List<Outlook.Folder> EnumerateFolders(Outlook.Folder parentFolder)
{
List<Outlook.Folder> allFolders = new List<Outlook.Folder>();
EnumerateFolders(parentFolder, allFolders);
return allFolders;
}
public void EnumerateFolders(Outlook.Folder parentFolder, List<Outlook.Folder> allFolders)
{
Outlook.Folders childFolders = parentFolder.Folders;
if (childFolders.Count > 0)
{
foreach (Outlook.Folder childFolder in childFolders)
{
try
{
bool isHidden = childFolder.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10F4000B");
if (!isHidden)
{
allFolders.Add(childFolder);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
// Call EnumerateFolders using childFolder.
EnumerateFolders(childFolder, allFolders);
}
}
}
The problem I am facing here is, if I create a new folder under root folder and execute the above code I am getting an error "MAPI property 0x10F4000B is not found". 0x10F4000B is for PT_ATTR_HIDDEN.
If I create new folder using OWA, then this property is available. It is not available only when I create the folder in Outlook 2013.
Can somebody please help me in understanding what is the problem here. Thanks in advance.
回答1:
You cannot expect any MAPI property is to be available. It just happens that OWA sets that property to false. Outlook only cares about the property being true. If the property is missing, it assumes the folder must be shown (PR_ATTR_HIDDEN = false).
来源:https://stackoverflow.com/questions/34268879/pr-attr-hidden-property-is-missing-when-a-new-folder-is-created-in-outlook-2013