共享邮箱上的 MailItem.GetConversation() [英] MailItem.GetConversation() on shared mailbox

查看:47
本文介绍了共享邮箱上的 MailItem.GetConversation()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码在对话中显示原始电子邮件的属性.

I am using following code to display properties from original email in conversation.

void DemoConversation()
{
    object selectedItem = 
        Application.ActiveExplorer().Selection[1];
    // For this example, you will work only with 
    //MailItem. Other item types such as
    //MeetingItem and PostItem can participate 
    //in Conversation.
    if (selectedItem is Outlook.MailItem)
    {
        // Cast selectedItem to MailItem.
        Outlook.MailItem mailItem =
            selectedItem as Outlook.MailItem; ;
        // Determine store of mailItem.
        Outlook.Folder folder = mailItem.Parent
            as Outlook.Folder;
        Outlook.Store store = folder.Store;
        if (store.IsConversationEnabled == true)
        {
            // Obtain a Conversation object.
            Outlook.Conversation conv =
                mailItem.GetConversation();
            // Check for null Conversation.
            if (conv != null)
            {
                // Obtain Table that contains rows 
                // for each item in Conversation.
                Outlook.Table table = conv.GetTable();
                Debug.WriteLine("Conversation Items Count: " +
                    table.GetRowCount().ToString());
                Debug.WriteLine("Conversation Items from Table:");
                while (!table.EndOfTable)
                {
                    Outlook.Row nextRow = table.GetNextRow();
                    Debug.WriteLine(nextRow["Subject"]
                        + " Modified: "
                        + nextRow["LastModificationTime"]);
                }
                Debug.WriteLine("Conversation Items from Root:");
                // Obtain root items and enumerate Conversation.
                Outlook.SimpleItems simpleItems 
                    = conv.GetRootItems();
                foreach (object item in simpleItems)
                {
                    // In this example, enumerate only MailItem type.
                    // Other types such as PostItem or MeetingItem
                    // can appear in Conversation.
                    if (item is Outlook.MailItem)
                    {
                        Outlook.MailItem mail = item
                            as Outlook.MailItem;
                        Outlook.Folder inFolder =
                            mail.Parent as Outlook.Folder;
                        string msg = mail.Subject
                            + " in folder " + inFolder.Name;
                        Debug.WriteLine(msg);
                    }
                    // Call EnumerateConversation 
                    // to access child nodes of root items.
                    EnumerateConversation(item, conv);
                }
            }
        }
    }
}

void EnumerateConversation(object item,
    Outlook.Conversation conversation)
{
    Outlook.SimpleItems items =
        conversation.GetChildren(item);
    if (items.Count > 0)
    {
        foreach (object myItem in items)
        {
            // In this example, enumerate only MailItem type.
            // Other types such as PostItem or MeetingItem
            // can appear in Conversation.
            if (myItem is Outlook.MailItem)
            {
                Outlook.MailItem mailItem =
                    myItem as Outlook.MailItem;
                Outlook.Folder inFolder =
                    mailItem.Parent as Outlook.Folder;
                string msg = mailItem.Subject
                    + " in folder " + inFolder.Name;
                Debug.WriteLine(msg);
            }
            // Continue recursion.
            EnumerateConversation(myItem, conversation);
        }
    }
}

它在我的个人收件箱和作为附加收件箱添加的共享邮箱上运行良好.

It works fine on my personal inbox and shared mailbox added as additional inbox.

但是我拥有完全访问权限但在我的 Outlook 客户端中自动映射的所有其他共享邮箱都不起作用.

But all other shared mailboxes which I have full access but have auto-mapped in my Outlook client doesn't work.

有谁知道 mailItem.GetConversation() 是否应该与未添加为附加帐户但自动映射的共享邮箱一起使用?

Does anyone know if mailItem.GetConversation() supposed to work with shared mailboxes which are not added as additional account but are auto-mapped?

因为在这些共享邮箱上,即使同一对话中有其他电子邮件,我也会收到 Conversation Items Count: 0.

Because on these shared mailboxes, I get Conversation Items Count: 0even if there are other emails in the same conversation.

谢谢.

推荐答案

它在我的个人收件箱和添加为附加收件箱的共享邮箱上运行良好.

It works fine on my personal inbox and shared mailbox added as additional inbox.

您似乎只是在个人资料中添加了第二个帐户,而不是共享邮箱.

It seems you just added a second account to the profile, not a shared mailbox.

GetConversation 将返回 Null(在 Visual Basic 中为空).如果商店不支持对话视图,则项目不存在对话(例如,Outlook 在经典联机模式下针对早于 Microsoft Exchange Server 2010 的 Microsoft Exchange 版本运行).

GetConversation returns Null (Nothing in Visual Basic) if no conversation exists for the item. No conversation exists for an item if the store does not support Conversation view (for example, Outlook is running in classic online mode against a version of Microsoft Exchange earlier than Microsoft Exchange Server 2010).

使用 IsConversationEnabled 属性Store 对象来确定商店是否支持 Conversation viewGetConversation 应该可以工作.

Use the IsConversationEnabled property of the Store object to determine whether the store supports Conversation view and GetConversation is supposed to work.

这篇关于共享邮箱上的 MailItem.GetConversation()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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