jpe*_*i39 7 email outlook vba outlook-vba
在工作中我使用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
Run Code Online (Sandbox Code Playgroud)
我得到了它的工作:
'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
Run Code Online (Sandbox Code Playgroud)