Outlook VBA-仅从仍在收件箱中的对话中移动电子邮件

Outlook VBA-仅从仍在收件箱中的对话中移动电子邮件,vba,outlook,Vba,Outlook,我已经调整了Outlook VBA中internet上的一个例程,该例程将收件箱中的对话中的所有电子邮件移动到特定文件夹 我通过以下方式移动电子邮件: 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 问题是:在这段对话中,我有

我已经调整了Outlook VBA中internet上的一个例程,该例程将收件箱中的对话中的所有电子邮件移动到特定文件夹

我通过以下方式移动电子邮件:

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
问题是:在这段对话中,我有时会收到以前已经移动到目标文件夹的旧电子邮件:它们出现在我的收件箱中,因为对话模式的工作方式

如果我尝试使用olItem.move DestFolder移动它,代码将失败,因为电子邮件已经在DestFolder中

如何检测电子邮件是否已在目标文件夹中,并仅当它不在目标文件夹中时才将其移动到目标文件夹中


提前感谢您的帮助

一个简单的方法就足够了

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

你能告诉我们剩下的代码吗?