【问题标题】:Deleting an email when subject contains certain words当主题包含某些单词时删除电子邮件
【发布时间】:2013-10-28 12:44:44
【问题描述】:

我在工作中使用 Microsoft Outlook,但 Outlook 规则的空间已用完。

我正在尝试创建一个 VBA 程序,当我收到它时会检查我的电子邮件,如果有一封主题中有指定字符串的电子邮件,它将删除它。

这是我尝试编写的代码,但无法正常工作:

Public Sub process_email(itm As Outlook.MailItem)
    Dim new_msg As MailItem

    If new_msg.subject Like "*keyword*" Then
        new_msg.Delete
    End If
End Sub

【问题讨论】:

  • 参见@JimmyPena 的THIS。使用它来捕获传入的邮件,然后将其删除。

标签: vba email outlook


【解决方案1】:

我让它工作了:

'deletes all emails with "Magic Carpet Ride" in the subject
        If InStr(itm.Subject, "Magic Carpet Ride") > 0 Then
            itm.UnRead = False
            itm.Save
            itm.Delete
            End
        End If

【讨论】:

    猜你喜欢
    • 2011-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多