简体   繁体   中英

Outlook VBA - Move only emails from conversation that are still in inbox

I have adjusted a routine found on the internet in Outlook VBA that moves all emails from a conversation in inbox to a specific folder.

I move my emails by getting them like:

olItem As MailItem 'Put email from conversation in olItem
DestFolder As Outlook.Folder 'Destination folder where i want to send my email
olItem.Move DestFolder

Problem is: in this conversation I have sometimes older emails that have already been moved to the destination folder earlier: they appear in my inbox because of the way conversation mode works.

If I try to move it with olItem.Move DestFolder , the code fails as the email is already in DestFolder.

How to detect if an email is already in the destination folder and move it to ONLY if it's not there already

Thank you in advance for your help

A simple method that may suffice.

On Error Resume Next
olItem.Move DestFolder
' Turn error bypass off once the purpose for it has been served
On Error GoTo 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM