Share via

how to move/copy mails from a trash folder to deleteItems on outlook 2021

Alex Brandt 0 Reputation points
2023-06-02T13:15:32.1833333+00:00

This is the script on VB but i need know where to replace the folders name to make it work properly

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] = 'Dan Wilson'")

While TypeName(myItem) <> "Nothing"

myItem.Move myDestFolder

Set myItem = myItems.FindNext

Wend

End Sub

Microsoft 365 and Office | Development | Other
Outlook | Windows | Classic Outlook for Windows | For business

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.