如何在对话中移动所有消息? [英] How to move all messages in a conversation?

查看:50
本文介绍了如何在对话中移动所有消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道如何一次移动对话中的所有消息.

I need to know how to move all of the messages in a conversation at once.

我的宏当前读取

Sub Archive()
    Set ArchiveFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders("Archive")
    For Each Msg In ActiveExplorer.Selection
        Msg.UnRead = False
        Msg.Move ArchiveFolder
    Next Msg
End Sub

但这只会移动最新消息...并且仅当对话完全崩溃时才可以!展开对话后,我无法存档.

But that only moves the latest message... and only when the conversation is fully collapsed! I can't Archive when the conversation is expanded.

推荐答案

如果要处理对话,则必须显式地进行.您可以使用 MailItem.GetConversation 从MailItem转到其对话,但是最好直接使用对话.

If you want to handle conversations, you'll have to do so explicitly. You can go from MailItem to its Conversation using MailItem.GetConversation, but you'd be better off working with conversations directly.

您要做的是:

  1. 从当前选择中获取所有对话标题
  2. 对于每个对话,获取单个项目
  3. 与他们一起进行归档.

以下C#代码对此进行了说明,并且对于移植到VBA来说应该很简单.

The following C# code illustrates this, and should be trivial to port to VBA.

Outlook.Selection selection = Application.ActiveExplorer().Selection;
Outlook.Selection convHeaders = selection.GetSelection( Outlook.OlSelectionContents.olConversationHeaders) as Outlook.Selection;
foreach (Outlook.ConversationHeader convHeader in convHeaders)
{
  Outlook.SimpleItems items = convHeader.GetItems();
  for (int i = 1; i <= items.Count; i++)
  {
    if (items[i] is Outlook.MailItem)
    {
      Outlook.MailItem mail =  items[i] as Outlook.MailItem;
      mail.UnRead = false;
      mail.Move( archiveFolder );
    }
    // else... not sure how if you want to handle different types of items as well  }
}

这篇关于如何在对话中移动所有消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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