You can check and avoid sending confidential data from MS Outlook by using the below script. Steps you can follow:
1. Enable macro in outlook
2. Click on Outlook Tools –> Macro –> Visual basic editor
3. In the editor window expand the Project tree –> Microsoft Office Outlook This outlook session
4. Copy and paste the below code
** This code will check whether there is any number exists in your mail body and alert you and ask for confirmation before sending.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim a As String
Dim b
Dim strMSG As String
a = Item.Body
b = Extract_Number_from_Text(a)
strMSG = “Number found: ##” & CStr(b) & “##. Do you want to send the message?”
If b =0 Then
If MsgBox(strMSG, vbInformation + vbYesNo, “Developed by: Sayem-masudur.sayem@hotmail.com”) = vbNo Then
Cancel = True
End If
End If
End Sub
Function Extract_Number_from_Text(Phrase As String) As Double
On Error Resume Next
Dim Length_of_String As Integer
Dim Current_Pos As Integer
Dim Temp As String
Length_of_String = Len(Phrase)
Temp = “”
For Current_Pos = 1 To Length_of_String
If (Mid(Phrase, Current_Pos, 1) = “-“) Then
Temp = Temp & Mid(Phrase, Current_Pos, 1)
End If
If (Mid(Phrase, Current_Pos, 1) = “.”) Then
Temp = Temp & Mid(Phrase, Current_Pos, 1)
End If
If (IsNumeric(Mid(Phrase, Current_Pos, 1))) = True Then
Temp = Temp & Mid(Phrase, Current_Pos, 1)
End If
Next Current_Pos
If Len(Temp) = 0 Then
Extract_Number_from_Text = 0
Else
Extract_Number_from_Text = CDbl(Temp)
End If
End Function
5. Now while sending mail your outlook will automatically check – whether there is any number in your mail body. If yes – it will prompt for confirmation. If you select no – your message will not be sent.