是否有一种方法可以遍历ConversationID
,EntryID
那里的所有邮件
,GetConversation
,ConversationIndex
并根据相同的ID号对其进行分组,以便可以将它们与Outlook find related
功能相同地打印出来。
为
outlook.GetItemFromID(id)
仅适用于EntryID
,这对所有邮件都是唯一的。
我试图遍历所有邮件,并在其中找到各自的ID号,如果有任何具有相同ID号的邮件,则进行匹配。 但是所有id似乎都是唯一的。
答案 0 :(得分:2)
您可以使用MailItem
类的GetConversation方法来获得一个Conversation对象,该对象代表该项目所属的会话。
GetConversation返回Null
(在Visual Basic中为Nothing
)。在以下情况下,该项目没有对话:
Conversation
视图(例如,Outlook在经典的在线模式下针对Microsoft Exchange Server 2010之前的Microsoft Exchange版本运行)。使用Store
对象的IsConversationEnabled属性来确定商店是否支持“对话”视图。下面的C#示例代码(对不起,我不熟悉python,但是Outlook对象模型对于所有编程语言都是通用的)假定浏览器窗口中的选定项目是邮件项目。该代码示例获取与所选邮件项目关联的会话,并枚举该会话中的每个项目,显示该项目的主题。
void DemoConversation()
{
object selectedItem =
Application.ActiveExplorer().Selection[1];
// This example uses only
// MailItem. Other item types such as
// MeetingItem and PostItem can participate
// in the conversation.
if (selectedItem is Outlook.MailItem)
{
// Cast selectedItem to MailItem.
Outlook.MailItem mailItem =
selectedItem as Outlook.MailItem;
// Determine the store of the mail item.
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 the 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 the 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 the 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 the 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);
}
}
}