如何在 Outlook 2007 中编写宏以将项目从收件箱移到另一个文件夹并将其标记为未读?

如何在 Outlook 2007 中编写宏以将项目从收件箱移到另一个文件夹并将其标记为未读?

我希望 Outlook 2007 中有一个宏,可以将选定的项目移动到收件箱的子文件夹中,并在移动时将其标记为未读。这样,我就可以分配按钮,快速将项目移动到我的今日交易和本周交易文件夹中。

非常感谢,

山姆

答案1

我在网站和网络上的其他地方搜索了这个问题,但无法很快找到一个简单的答案,所以我自己编写了代码。以下是为下一个想要实现此目标的人提供的:

Option Explicit

Public Sub Today()

Dim myFolder As Folder

    Set myFolder = GetInboxSubFolder("* 0. Today")
    If Not myFolder Is Nothing Then
        MoveItemAndMarkAsUnread myFolder
    End If

End Sub

Private Function GetInboxSubFolder(folderName As String) As Folder

Dim myNamespace As NameSpace
Dim myInbox As Folder

    Set myNamespace = Application.GetNamespace("MAPI")
    Set myInbox = myNamespace.GetDefaultFolder(olFolderInbox)
    Set GetInboxSubFolder = myInbox.Folders(folderName)

End Function

Private Sub MoveItemAndMarkAsUnread(myFolder As Folder)

Dim myExplorer As Explorer
Dim mySelection As Selection

    Set myExplorer = Application.ActiveExplorer
    Set mySelection = myExplorer.Selection

Dim i As Integer
Dim myItem As MailItem

    For i = mySelection.Count To 1 Step -1

        mySelection.Item(i).UnRead = True
        mySelection.Item(i).Move myFolder

    Next i

End Sub

希望这对某人有用

相关内容