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

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

问题描述

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

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天全站免登陆