I want to move my emails from sent items to another folder based on the subject contains "Drive 20-Feb-23" using vba code.
I want to move my emails from sent items to another folder based on the subject contains "Drive 20-Feb-23" using vba code.
On
Do you want the messages to go to a different folder immediately after you send them? Trap the Application.ItemSend event (the item being sent will be passed to your handler), check the subject or any other appropriate condition, and set the MailItem.SaveSentMessageFolder property to the appropriate folder from the same (!) store.
You need to use the Move method which moves a Microsoft Outlook item to a new folder.
To find items with a specified subject you can use the
Find/FindNextorRestrictmethods of theItemsclass. The simplest DASL syntax may look like that:But a better approach would be to use a substring matching mechanism instead:
Read more about these methods in the articles that I wrote for the technical blog: