Sensitivity check while sending email

How many times you have sent an email and then realized that there are some recipients in entire mail list who should not get that mail? Often people make habit of `reply to all` while replying any message and ends up with question to mail admin “Can you stop this email?!”

There are number of commercial tools and add-ons available that can be pushed to end users email client from mail server to check mail sensitivity before sending.

However for a small organization of 10 – 20 size, it might not be cost effective to go for such solutions.

This example below shows, how to develop your own outlook macro and distribute it among your colleagues. It has been tested with Outlook 2013.

Features

  1. Popup to check sensitivity i.e. Confidential, Internal and Public before sending an email.
  2. Change subject line and mark email as confidential or internal after subject
  3. Allow user to cancel send mail and review again.

Steps

  1. Open MS outlook and click on Developer Menu then visual basic.

1

  1. In the visual basic window, insert a user form and design it as below. Click on insert then user form.

2

  1. Check recipient list for internal and confidential mails base on their email domain and if there any recipients with other domain found in the list a popup will be given to user for his/her consent. Besides mail subject line will be modified by adding confidential or Internal at the end subject to users selection.

 

Add following code in ItemSend event under ThisOutlookSession object..

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

Dim myFrm As frmOption

Dim Recipients As Outlook.Recipients

Dim recip As Outlook.Recipient

Dim pa As Outlook.PropertyAccessor

Dim mailadd As String

Dim i

Dim resp

Set myFrm = New frmOption

myFrm.Show

On Error Resume Next

‘ use lower case for the address

‘ LCase converts all addresses in the To field to lower case

If myFrm.optInt.Value = True Then

Set Recipients = Item.Recipients

If InStr(1, Item.Subject, “Internal”, vbTextCompare) = 0 Then

Item.Subject = Item.Subject & ” – (Internal)”

End If

For i = Recipients.Count To 1 Step -1

Set recip = Recipients.Item(i)

mailadd = recip.AddressEntry.GetExchangeUser.PrimarySmtpAddress

If Right(LCase(mailadd), 14) <> “yourdomian.com” Then

‘–here 14 is the length of yourdomain.com

resp = MsgBox(“There are external email addresses in the recipient list!” & vbCrLf & _

“Do you still want to send this mail?”, vbYesNo, “Alert!”)

If resp = vbNo Then

Cancel = True

End If

Exit For

End If

Next i

End If

 If myFrm.OptConf.Value = True Then

Set Recipients = Item.Recipients

If InStr(1, Item.Subject, “Confidential”, vbTextCompare) = 0 Then

Item.Subject = Item.Subject & ” – (Confidential)”

End If

For i = Recipients.Count To 1 Step -1

Set recip = Recipients.Item(i)

mailadd = recip.AddressEntry.GetExchangeUser.PrimarySmtpAddress

If Right(LCase(mailadd), 14) <> “yourdomain.com” Then

‘–here 14 is the length of yourdomain.com

   resp = MsgBox(“There external email addresses in the recipient list!” & vbCrLf & _

“Do you still want to send this mail?”, vbYesNo, “Alert!”)

If resp = vbNo Then

Cancel = True

End If

Exit For

End If

Next i

End If

 

If myFrm.optPub.Value = True Then

Cancel = False

End If

 

If myFrm.OptDonSend = True Then

Cancel = True

End If

End Sub

 

  1. Put following codes to handle user action on the form…

Private Sub cmdOk_Click()

If Me.OptConf = False And Me.optInt = False And Me.optPub = False And Me.OptDonSend = False Then

MsgBox “Please select a sensitivity level.”, vbOKOnly, “Alert”

Else

Unload Me

End If

End Sub

 Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If Me.OptConf = False And Me.optInt = False And Me.optPub = False And Me.OptDonSend = False Then

MsgBox “Please select a sensitivity level.”, vbOKOnly, “Alert”

Cancel = (CloseMode = 0)

End If

End Sub

And you are done with the macro!! Next you need to get this macro signed with digital certificate. Otherwise every time you run Outlook, it will prompt you to enable this macro. To do so please follow the steps written in http://www.howto-outlook.com/howto/selfcert.htm

That’s all folks……..!

About Mamun Shaheed

I love to imagine....I guess thats the only thing that keeps me going and going and going....
This entry was posted in Email and tagged , , , . Bookmark the permalink.

Leave a comment