【问题标题】:Outlook VBA - Move only emails from conversation that are still in inboxOutlook VBA - 仅移动仍在收件箱中的对话中的电子邮件
【发布时间】:2017-07-02 05:21:58
【问题描述】:

我在 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 中。

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

提前感谢您的帮助

【问题讨论】:

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

标签: vba outlook


【解决方案1】:

一个简单的方法就足够了。

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

【讨论】:

    猜你喜欢
    • 2015-10-02
    • 2011-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    相关资源
    最近更新 更多