PDA

View Full Version : Macro Creation for Prompt After Send button is Pressed



smurphy619
08-07-2016, 10:36 AM
I'm hoping someone can help me with this one. I'd like to have a prompt appear when i hit the "send" button (or Ctrl + Enter alternatively) similar to the following (i think) but with some more logic in it.


Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If MsgBox("Do you want to continue sending the mail?", vbOKCancel) <> vbOK Then
Cancel = True
End If
End Sub


My hope is to have a box/prompt appear only when the letters "ABCD" and/or "EFGH" are found within the body of the email. If these letters are found, I'd like the prompt to
appear saying "Did you include the Job Number in the subject line?" and then if "Yes" is clicked the email is sent, if "No..." is selected, the Send is cancelled and
we're returned to the draft. Is something like this possible?

Greatly appreciate the help,

Sean Murphy

gmayor
08-07-2016, 08:36 PM
The following - in the ThisOutlookSession module should work.

Option Explicit

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If InStr(1, Item.Body, "ABCD") > 0 Or InStr(1, Item.Body, "EFGH") > 0 Then
If MsgBox("Did you include the Job Number in the subject line?", vbOKCancel) <> vbOK Then
Cancel = True
End If
End If
End Sub