这个例子使用C#,Visual Studio 2010开发,是基于Outlook 2010的应用。当你选中一个邮件然后在Ribbon上点击按钮后所用与这个会话相关的邮件都会被打开。
主要代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Tools.Ribbon; using Outlook = Microsoft.Office.Interop.Outlook; namespace GetConversationMails { public partial class Ribbon1 { private void Ribbon1_Load(object sender, RibbonUIEventArgs e) { } private void button1_Click(object sender, RibbonControlEventArgs e) { Outlook.Application objApplication = Globals.ThisAddIn.Application; Outlook.Explorer objExplorer = objApplication.ActiveExplorer(); for (int i = 0; i <= objExplorer.Selection.Count; i++) { if (i > 0) { var obj = objExplorer.Selection[i]; if (obj is Outlook.MailItem) { Outlook.MailItem objMailItem = (Outlook.MailItem)obj; Outlook.Conversation objConversation = objMailItem.GetConversation(); Outlook.SimpleItems objRootItems = objConversation.GetRootItems(); objExplorer.ClearSelection(); foreach (var Element1 in objRootItems) { if (Element1 is Outlook.MailItem) { Outlook.MailItem objRootItem = (Outlook.MailItem)Element1; //对根邮件的处理。这里的示例为在Inspector中显示。 objRootItem.Display(); Outlook.SimpleItems objChildrenItem = objConversation.GetChildren(objRootItem); foreach (var Element2 in objChildrenItem) { if (Element2 is Outlook.MailItem) { Outlook.MailItem objChildItem = (Outlook.MailItem)Element2; //对子邮件的处理,这里的示例为在Inspector中显示。 objChildItem.Display(); } } } } } } } } } }相关资源下载: http://download.csdn.net/detail/tx_officedev/3853114