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

Outlook
Outlook
A family of Microsoft email and calendar products.
4,172 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.
4,075 questions
{count} votes

Your answer

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