Warning pop up before sending to a specific email address (Outlook)

iluvsafc

New Member
Joined
Jun 15, 2009
Messages
28
Hi all, i'm looking for some VBA code that will trigger a warning pop up box before sending an email to a specific email address. Any help would be much appreciated.

Thanks!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Looks like this would go in a class module:

However, I am not having much success, possibly due to company security

VBA Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

If Item.To = "xxx@xxx.com" Then
    MsgBox "Warning"
End If

End Sub
 
Upvote 0
Looks like this would go in a class module:

However, I am not having much success, possibly due to company security

VBA Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

If Item.To = "xxx@xxx.com" Then
    MsgBox "Warning"
End If

End Sub
Thanks for this, it works exactly how i described, however, the email still sends when ok is pressed. Is there a way of including two options on the message box, 'send' and 'dont send'?

Thanks in advance!
 
Upvote 0
Untested, something like:

VBA Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
 
Dim prompt As String
 
If Item.To = "xxx@xxx.com" Then
prompt = "Are you sure you want to send " & Item.Subject & "?"
    If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
    Cancel = True
    End If
End If
 
End Sub
 
Upvote 0
Solution
Untested, something like:

VBA Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
 
Dim prompt As String
 
If Item.To = "xxx@xxx.com" Then
prompt = "Are you sure you want to send " & Item.Subject & "?"
    If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
    Cancel = True
    End If
End If
 
End Sub
Amazing, thanks for your help!
 
Upvote 0

Forum statistics

Threads
1,223,396
Messages
6,171,864
Members
452,427
Latest member
samk379

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top