我们是开发人员的Outlook插件。我们提供了一个按钮工作作为默认发送按钮的替代。我们需要将按钮回复的所有MailItem保存到特定类别。 当用户回复电子邮件时(在新的检查员中),我如何才能回复主MailItem?
答案 0 :(得分:2)
用户可以从Explorer或Inspector回复。
如果是资源管理器,请捕获Explorer.SelectionChange事件并在所选项目上设置事件接收器。您可以捕获MailItem.Reply / ReplyAll / Forward事件。
如果是检查员,则捕获Application.Inspectors.NewInspector事件,并在从Inspector.CurrentItem属性返回的MailItem上设置事件接收器。然后,您将再次捕获MailItem.Reply / ReplyAll / Forward事件。
答案 1 :(得分:1)
您可以使用MailItem类的GetConversation方法,该方法返回表示此项目所属对话的Conversation对象。
如果项目没有对话,则GetConversation返回Null(在Visual Basic中为Nothing)。在以下情况下,项目不存在对话:
对话表示一个或多个文件夹和商店中的一个或多个项目。如果将对话中的项目移动到“已删除邮件”文件夹,然后使用GetChildren,GetRootItems或GetTable方法枚举对话,则该项目将不会包含在返回的对象中。
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, only enumerate 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, only enumerate 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);
}
}
}