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

Alex Brandt 0 Reputation points

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


End Sub

A family of Microsoft email and calendar products.
3,403 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,709 questions
{count} votes