Hi, I have found a very useful VBA code to remove a line of text in an email but I need to run it manually for it to work.
What would I need to add in order to have it automatically run each time i receive a new email in my inbox?
What would I need to add in order to have it automatically run each time i receive a new email in my inbox?
Code:
Option Explicit
Sub RemoveExpressionFOLDER()
Dim outFldr As Folder
Dim outItems As Items
Dim outMailItem As MailItem
Dim i As Long
Dim cleanCount As Long
Set outFldr = ActiveExplorer.CurrentFolder
Set outItems = outFldr.Items
For i = 1 To outItems.Count
If outItems(i).Class = olMail Then
Set outMailItem = outItems(i)
With outMailItem
'Debug.Print .Subject
If InStr(.body, "words to remove here ") Then
If .BodyFormat = olFormatHTML Then
.HTMLBody = Replace(.HTMLBody, "words to remove here", "")
Else
.body = Replace(.body, "words to remove here", "")
End If
.Save
cleanCount = cleanCount + 1
End If
End With
End If
Next i
End Sub