Delete email when a topic contains specific words

At work, I use Microsoft Outlook, and I do not have enough space for Outlook rules.

I am trying to create a VBA procedure that will check my email as it is received, and if there is a message with the specified line in the subject, it will delete it.

This is what I tried to code, but I could not get it to work:

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 
+6
source share
1 answer

I got it for work:

 '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 
+5
source

Source: https://habr.com/ru/post/956330/


All Articles