A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Send Confirmation (for external emails)



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 18th 08, 12:42 PM posted to microsoft.public.outlook.program_vba
Mike
external usenet poster
 
Posts: 332
Default Send Confirmation (for external emails)

Hi,

My boss asked me to come up with a way that users would see a prompt when
they send an email (to absolutely confirm they want to send it, to ensure it
has the correct content and is addressed correctly).

After some searching around, I found some code which will do this (which is
shown below).

The code makes the prompt appear for all messages, but thinking about this
some more (and do not annoy everyone), would it be possible to only have the
prompt appear when email someone from outside our organisation?

Doing a clever lookup in VB to check against users in the GAL might be a bit
tricky, so I was thinking a simply list of internal staff in the code(we only
have 60 so it's not a headache to keep this list updated). The code would
check if only internal people were in either the to, cc or bcc fields then it
wouldn't show the prompt. If one person who wasn't on the list appeared (i.e.
it was being sent to someone outside) then the prompt would show.

Is this possible? and if so, how? My VB skills are poor to say the least.
The code is below if anyone care to offer advice on how I can add the list
and have it check upon sending?!?

Many thanks

[CODE STARTS BELOW]

Option Explicit
Dim WithEvents objInspectors As Inspectors
Dim WithEvents objMyNewMail As MailItem

Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
End Sub

Private Sub Application_Quit()
Set objInspectors = Nothing
Set objMyNewMail = Nothing
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class olMail Then Exit Sub
Set objMyNewMail = Inspector.CurrentItem
End Sub

Private Sub objMyNewMail_Send(Cancel As Boolean)
If MsgBox("Are you sure you want to send this message?", vbYesNo +
vbQuestion _
, "Send Confirmation") = vbNo Then
Cancel = True
End If
End Sub

[CODE FINISHES HERE]

Ads
  #2  
Old April 18th 08, 12:58 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Send Confirmation (for external emails)

If you use Exchange, iterate the Recipients collection for the message you want to send. For any recipient, if Recipient.AddressEntry.Type is "SMTP" and not "EX" then you know it's going outside the Exchange server.

Instead of using MailItem.Send, why not simplify matters considerably and use the Application.ItemSend event?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Mike" wrote in message ...
Hi,

My boss asked me to come up with a way that users would see a prompt when
they send an email (to absolutely confirm they want to send it, to ensure it
has the correct content and is addressed correctly).

After some searching around, I found some code which will do this (which is
shown below).

The code makes the prompt appear for all messages, but thinking about this
some more (and do not annoy everyone), would it be possible to only have the
prompt appear when email someone from outside our organisation?

Doing a clever lookup in VB to check against users in the GAL might be a bit
tricky, so I was thinking a simply list of internal staff in the code(we only
have 60 so it's not a headache to keep this list updated). The code would
check if only internal people were in either the to, cc or bcc fields then it
wouldn't show the prompt. If one person who wasn't on the list appeared (i.e.
it was being sent to someone outside) then the prompt would show.

Is this possible? and if so, how? My VB skills are poor to say the least.
The code is below if anyone care to offer advice on how I can add the list
and have it check upon sending?!?

Many thanks

[CODE STARTS BELOW]

Option Explicit
Dim WithEvents objInspectors As Inspectors
Dim WithEvents objMyNewMail As MailItem

Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
End Sub

Private Sub Application_Quit()
Set objInspectors = Nothing
Set objMyNewMail = Nothing
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class olMail Then Exit Sub
Set objMyNewMail = Inspector.CurrentItem
End Sub

Private Sub objMyNewMail_Send(Cancel As Boolean)
If MsgBox("Are you sure you want to send this message?", vbYesNo +
vbQuestion _
, "Send Confirmation") = vbNo Then
Cancel = True
End If
End Sub

[CODE FINISHES HERE]

  #3  
Old April 18th 08, 02:28 PM posted to microsoft.public.outlook.program_vba
Mike
external usenet poster
 
Posts: 332
Default Send Confirmation (for external emails)

Sue,

Thanks for your quick reply. We are using Exchange 2003 and Outlook 2003.
Unfortunately I have no idea how to iterate the recipients collection, or
even what that means.

Also, using the Application.ItemSend instead of MailItme.Send sounds
plausable but again I'm not sure why I would do this. What are the advantages?

The code in my original post works, everytime. I got it from searching for a
solution and found a forum with this code posted previously by someone. I
tried it and it works fine. I'm not a programmer, nor do I know anything
about VBA. Nothing in the slightest actually.

I appreciate you are a programmer and have offered your advice for free, for
which I'm very grateful. However, I need to find someone willing to amend the
code as I don't have the knowledge to be able to do it myself.

Is there anyone out there willing to program for free?!

Many thanks

Michael


"Sue Mosher [MVP-Outlook]" wrote:

If you use Exchange, iterate the Recipients collection for the message you want to send. For any recipient, if Recipient.AddressEntry.Type is "SMTP" and not "EX" then you know it's going outside the Exchange server.

Instead of using MailItem.Send, why not simplify matters considerably and use the Application.ItemSend event?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Mike" wrote in message ...
Hi,

My boss asked me to come up with a way that users would see a prompt when
they send an email (to absolutely confirm they want to send it, to ensure it
has the correct content and is addressed correctly).

After some searching around, I found some code which will do this (which is
shown below).

The code makes the prompt appear for all messages, but thinking about this
some more (and do not annoy everyone), would it be possible to only have the
prompt appear when email someone from outside our organisation?

Doing a clever lookup in VB to check against users in the GAL might be a bit
tricky, so I was thinking a simply list of internal staff in the code(we only
have 60 so it's not a headache to keep this list updated). The code would
check if only internal people were in either the to, cc or bcc fields then it
wouldn't show the prompt. If one person who wasn't on the list appeared (i.e.
it was being sent to someone outside) then the prompt would show.

Is this possible? and if so, how? My VB skills are poor to say the least.
The code is below if anyone care to offer advice on how I can add the list
and have it check upon sending?!?

Many thanks

[CODE STARTS BELOW]

Option Explicit
Dim WithEvents objInspectors As Inspectors
Dim WithEvents objMyNewMail As MailItem

Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
End Sub

Private Sub Application_Quit()
Set objInspectors = Nothing
Set objMyNewMail = Nothing
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class olMail Then Exit Sub
Set objMyNewMail = Inspector.CurrentItem
End Sub

Private Sub objMyNewMail_Send(Cancel As Boolean)
If MsgBox("Are you sure you want to send this message?", vbYesNo +
vbQuestion _
, "Send Confirmation") = vbNo Then
Cancel = True
End If
End Sub

[CODE FINISHES HERE]


  #4  
Old April 18th 08, 04:02 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Send Confirmation (for external emails)

The advantage of using Application.ItemSend is that it fires for every outgoing item. The technique that your original code uses cannot handle the scenario where the user has more than one new message open at the same time.

To iterate means to loop through, as in this example:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objMyNewMail As Outlook.mailItem
Dim objRecip As Outlook.Recipient
Dim blnIsExternal As Boolean
If Item.Class = olMail Then
Set objMyNewMail = Item
For Each objRecip In objMyNewMail.Recipients
If UCase(objRecip.AddressEntry.Type) = "SMTP" Then
blnIsExternal = True
Exit For
End If
Next
If blnIsExternal Then
' this is where your code to prompt the user goes
If MsgBox("Are you sure you want to send this message?", _
vbYesNo + vbQuestion, _
, "Send Confirmation") = vbNo Then
Cancel = True
End If
End If
End If
Set objMyNewMail = Nothing
Set objRecip = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Mike" wrote in message ...
Sue,

Thanks for your quick reply. We are using Exchange 2003 and Outlook 2003.
Unfortunately I have no idea how to iterate the recipients collection, or
even what that means.

Also, using the Application.ItemSend instead of MailItme.Send sounds
plausable but again I'm not sure why I would do this. What are the advantages?

The code in my original post works, everytime. I got it from searching for a
solution and found a forum with this code posted previously by someone. I
tried it and it works fine. I'm not a programmer, nor do I know anything
about VBA. Nothing in the slightest actually.

I appreciate you are a programmer and have offered your advice for free, for
which I'm very grateful. However, I need to find someone willing to amend the
code as I don't have the knowledge to be able to do it myself.

Is there anyone out there willing to program for free?!

Many thanks

Michael


"Sue Mosher [MVP-Outlook]" wrote:

If you use Exchange, iterate the Recipients collection for the message you want to send. For any recipient, if Recipient.AddressEntry.Type is "SMTP" and not "EX" then you know it's going outside the Exchange server.

Instead of using MailItem.Send, why not simplify matters considerably and use the Application.ItemSend event?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Mike" wrote in message ...
Hi,

My boss asked me to come up with a way that users would see a prompt when
they send an email (to absolutely confirm they want to send it, to ensure it
has the correct content and is addressed correctly).

After some searching around, I found some code which will do this (which is
shown below).

The code makes the prompt appear for all messages, but thinking about this
some more (and do not annoy everyone), would it be possible to only have the
prompt appear when email someone from outside our organisation?

Doing a clever lookup in VB to check against users in the GAL might be a bit
tricky, so I was thinking a simply list of internal staff in the code(we only
have 60 so it's not a headache to keep this list updated). The code would
check if only internal people were in either the to, cc or bcc fields then it
wouldn't show the prompt. If one person who wasn't on the list appeared (i.e.
it was being sent to someone outside) then the prompt would show.

Is this possible? and if so, how? My VB skills are poor to say the least.
The code is below if anyone care to offer advice on how I can add the list
and have it check upon sending?!?

Many thanks

[CODE STARTS BELOW]

Option Explicit
Dim WithEvents objInspectors As Inspectors
Dim WithEvents objMyNewMail As MailItem

Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
End Sub

Private Sub Application_Quit()
Set objInspectors = Nothing
Set objMyNewMail = Nothing
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class olMail Then Exit Sub
Set objMyNewMail = Inspector.CurrentItem
End Sub

Private Sub objMyNewMail_Send(Cancel As Boolean)
If MsgBox("Are you sure you want to send this message?", vbYesNo +
vbQuestion _
, "Send Confirmation") = vbNo Then
Cancel = True
End If
End Sub

[CODE FINISHES HERE]


  #5  
Old May 25th 14, 05:49 PM
dohodoho dohodoho is offline
Junior Member
 
First recorded activity at Outlookbanter: May 2014
Posts: 1
Default

Quote:
My boss asked me to come up with a way that users would see a prompt when they send an email (to absolutely confirm they want to send it, to ensure it has the correct content and is addressed correctly).
Hi,
I would like to tip you of a solution that we use at our company called SafeSend. It is a simple add-in that asks a confirmation for sending emails to external recipients. I am sure you can configure it to ask for a cofirmation to all recipients. Hope you like it
http://www.safesendsoftware.com
Attached Images
File Type: jpg safesend_large.jpg (73.5 KB, 0 views)
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I send ICS files as attachments and from some outlooks I get back a winmail.dat as confirmation Jens[_2_] Outlook - General Queries 2 February 4th 08 07:08 PM
Outlook will receive but not send external emails In_the_dark Outlook - Installation 5 January 29th 08 03:38 AM
message sent-confirmation of emails sent-weird reply curious kid Outlook - General Queries 1 January 13th 08 06:20 PM
message sent-confirmation of emails sent-weird reply curious kid Outlook - General Queries 1 January 13th 08 08:23 AM
How do I setup a warning message for external emails? Melanie Outlook - Using Contacts 0 July 14th 06 05:39 PM


All times are GMT +1. The time now is 12:50 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.