检测 Outlook 2007 中的自动存档设置/存储

发布于 2024-07-14 21:33:22 字数 395 浏览 4 评论 0原文

我想编写一个简单的 Outlook 2007 AddIn,允许我手动自动存档邮件。 也就是说,我右键单击一封邮件,选择“自动存档”,它就会移至我的“存档”文件夹中。

不幸的是,我似乎无法检测哪一个是存档存储。 我知道 Application.GetNamespace("MAPI").Stores 是我所有商店的列表,其中包括我的存档商店。 但我似乎没有找到一种方法来检测商店是否是存档商店。

在建议对 store.DisplayName 进行简单字符串匹配之前,请记住本地化(在德语中,商店是“Archivordner”,这与英语明显不同)。

我认为可以访问“自动存档”设置来获取文件名,然后与 store.FilePath 进行匹配,但我无法在任何地方找到此设置。

有什么建议么?

I want to write a simple Outlook 2007 AddIn that allows me to manually Auto-Archive mails. That is, I right-click a mail, select Auto-Archive and it gets moved into my Archive folder.

Unfortunately, I do not seem to be able to detect which one is the Archive Storage. I know that Application.GetNamespace("MAPI").Stores is a list of all my stores, and this includes my Archive Store. But I do not seem to find a way to detect if a store is the Archive Store or not.

Before you recommend simple string matching against store.DisplayName keep in mind localization (in German, the Store is "Archivordner", which is obviously different from the english one).

I was thinking that it could be possible to access the Auto Archive setting to get the Filename and then match against store.FilePath, but I am unable to find this setting anywhere.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天荒地未老 2024-07-21 21:33:22

好的,找到了。 秘密是 IPC.MS.Outlook.AgingProperties,它有点奇怪且没有记录,但对我来说已经足够了。

    private bool GetArchiveFilename(MAPIFolder fld, out string archiveFileName)
    {
        bool result = false;
        archiveFileName = string.Empty;
        if (fld != null)
        {
            StorageItem si = fld.GetStorage("IPC.MS.Outlook.AgingProperties", OlStorageIdentifierType.olIdentifyByMessageClass);

            try
            {
                archiveFileName = si.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x6859001E").ToString();
                result = true;
            }
            catch (COMException)
            {
                return GetArchiveFilename(fld.Parent as MAPIFolder, out archiveFileName);
            }
        }
        return result;
    }

Okay, found it. The Secret is IPC.MS.Outlook.AgingProperties and it's a bit weird and undocumented, but it's good enough for me.

    private bool GetArchiveFilename(MAPIFolder fld, out string archiveFileName)
    {
        bool result = false;
        archiveFileName = string.Empty;
        if (fld != null)
        {
            StorageItem si = fld.GetStorage("IPC.MS.Outlook.AgingProperties", OlStorageIdentifierType.olIdentifyByMessageClass);

            try
            {
                archiveFileName = si.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x6859001E").ToString();
                result = true;
            }
            catch (COMException)
            {
                return GetArchiveFilename(fld.Parent as MAPIFolder, out archiveFileName);
            }
        }
        return result;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文