簡體   English   中英

Outlook VBA - 僅移動仍在收件箱中的對話中的電子郵件

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM