I found this phrase checker in the body of an Outlook email here which works flawlessly.
The code shared on the above link is as follows:
Public Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) On Error Resume Next If InStr(Item.Body, "(Client Name)") Then If MsgBox("Are you sure to send this message?", vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Message Text Warning") = vbNo Then Cancel = True End If End If End Sub
But my actual requirement is to check an outgoing Outlook Email for the following criteria:
If body contains specific text AND If the Sending / From Email address is one of the few specific addresses.
Then ask the user if the user still wants to send this email through the specific address (preferably show the Sending / From Email Address here)?
Update 1st January 2017:
The following helps check the email address from which I am sending the email:
But when I try to use it with the previous
If statement then it doesn't work, so now this is the next challenge I'm looking to solve:
If InStr(Item.Body, "(Client Name)") And InStr(LCase(Item.SendUsingAccount), "email@example.com") Then
In other words, both
If criteria aren't working if they are run together (doesn't matter which one I put first and which one as second), but if they are run separately (single) then they work just fine.