0

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:

InStr(LCase(Item.SendUsingAccount), "user@domain.ext")

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), "user@domain.ext") 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.

  • Update: The following helps check the email address from which I am sending the email InStr(LCase(Item.SendUsingAccount), "user@domain.ext") 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), "user@domain.ext") Then – Xeirus Jan 1 '17 at 10:51
  • Have you considered chaining both If statements? – T. Novais Jul 3 '17 at 16:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.