在Outlook 2013中创建新文件夹时缺少PR_ATTR_HIDDEN属性 [英] PR_ATTR_HIDDEN property is missing when a new folder is created in outlook 2013

查看:206
本文介绍了在Outlook 2013中创建新文件夹时缺少PR_ATTR_HIDDEN属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c#开发Outlook 2013插件.作为要求的一部分,我需要枚举所有可见文件夹.以下是我正在使用的示例代码.

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);
        }
    }
}

我在这里面临的问题是,如果我在根文件夹下创建一个新文件夹并执行上述代码,则会收到错误消息找不到MAPI属性0x10F4000B". 0x10F4000B用于PT_ATTR_HIDDEN.

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.

如果我使用OWA创建新文件夹,则此属性可用.仅当我在Outlook 2013中创建文件夹时,它才可用.

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.

推荐答案

您不能期望任何MAPI属性都可用. OWA刚好将该属性设置为false. Outlook只关心该属性为true.如果缺少该属性,则假定必须显示该文件夹(PR_ATTR_HIDDEN = false).

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).

这篇关于在Outlook 2013中创建新文件夹时缺少PR_ATTR_HIDDEN属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆