如何将“移动收件箱”项目更改为特定文件夹

时间:2018-10-29 15:13:35

标签: outlook outlook-vba

我的Outlook收件箱文件夹中有很多项目。我想通过VBA将它们移动到特定的文件夹。我找不到将项目移动到文件夹的方法。我需要你的帮助。谢谢

1 个答案:

答案 0 :(得分:0)

您要将收件箱项目移动到特定文件夹吗?

您可以使用Move方法将Microsoft Outlook项目移动到新文件夹。例如:

Sub MoveItems() 
 Dim myNameSpace As Outlook.NameSpace 
 Dim myInbox As Outlook.Folder 
 Dim myDestFolder As Outlook.Folder 
 Dim myItems As Outlook.Items 
 Dim myItem As Object 

 Set myNameSpace = Application.GetNamespace("MAPI") 
 Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox) 
 Set myItems = myInbox.Items 
 Set myDestFolder = myInbox.Folders("Personal Mail") 
 Set myItem = myItems.Find("[SenderName] = 'Eugene Astafiev'") 
 While TypeName(myItem) <> "Nothing" 
  myItem.Move myDestFolder 
  Set myItem = myItems.FindNext 
 Wend 
End Sub

有关更多信息,请参考此链接:

VBA to move read emails to specific folders