[英]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.我在 Outlook VBA 中调整了 Internet 上的一个例程,该例程将所有电子邮件从收件箱中的对话移动到特定文件夹。
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.如果我尝试使用olItem.Move DestFolder移动它,代码将失败,因为电子邮件已经在 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.