我正在尝试创建一个子程序,当调用该子程序时,该子程序只会将当前所选邮件移动到Outlook中的默认垃圾文件夹。
我很难找到任何可以使用的参考资料,并希望得到帮助。
答案 0 :(得分:0)
这对你有用
Sub MoveItems()
Dim myDestFolder As Outlook.Folder
Set myDestFolder = Application.GetNamespace("MAPI").Folders("youremailaddress").Folders("[Gmail]").Folders("Spam") ' or Junk
Dim myItem As Object
Set myItem = GetCurrentItem
myItem.Move myDestFolder
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select
GetCurrentItem.UnRead = False
Set objApp = Nothing
End Function
答案 1 :(得分:0)
我的宏版本:
Public Sub MarkSelectedAsSpam()
Dim junkFolder As Outlook.Folder
Set junkFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderJunk)
Dim email As Object
For Each email In Application.ActiveExplorer.Selection
email.Move junkFolder
Next
End Sub
将选定的电子邮件删除到垃圾文件夹中。