我有时会收到想要保留的邮件,但将它们移动到适当的文件夹可能会很麻烦。我该如何执行一个脚本,将我正在查看的电子邮件移动(类似于使用C-S-v)到一个名为“缓冲区”的特定文件夹中?我正在使用Outlook 2007。
谢谢。
编辑:没有任何可以通过规则自动化此过程的标准。这只是我在观察时做出的判断。
谢谢。
编辑:没有任何可以通过规则自动化此过程的标准。这只是我在观察时做出的判断。
Sub MoveSelectedMessagesToFolder()
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim obj As Object
Dim msg As Outlook.mailItem
Set objNS = Application.GetNamespace("MAPI")
On Error Resume Next
Set objFolder = objNS.Folders.item("Personal Folders").Folders.item("Buffer")
On Error GoTo 0
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
Exit Sub
End If
For Each obj In ActiveExplorer.Selection
If TypeName(obj) = "MailItem" Then
Set msg = obj
msg.Move objFolder
End If
Next obj
End Sub
这是我正在使用的代码。
Sub MoveSelectedMessagesToFolder()
'Originally written by Chewy Chong
'Taken from http://verychewy.com/archive/2006/04/12/outlook-macro-to-move-an-email-to-folder.aspx
'Thanks Chewy!
'Ken
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
'For the "Item" portion, I used the name of the folder exactly as it appear in the ToolTip when I hover over it.
Set objFolder = objNS.Folders.Item("Personal Folders").Folders.Item("Buffer")
'Assume this is a mail folder
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is selected
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move objFolder
End If
End If
Next
工具 -> 规则和警报
然后创建一个新规则,将符合任何条件的所有邮件删除/标记为已读/移动到文件夹/这些任意组合。
编辑: 如果您不想要规则/无法创建符合条件的规则,则可以创建一个宏(工具 -> 宏)将其移动到文件夹,然后将其绑定到快捷方式。