It can bring out many troubles if you send confidential files to others via email in your Outlook. Therefore, this article will teach you how to get warned before you attach confidential files to your Outlook mail.
Perhaps you are keeping many confidential documents about your company. As we all know, confidential files are extremely significant. You should never send out any of them to others without permissions in that not only can it bring many troubles to your enterprise, but also it can directly result in your unemployment if the case is considerably severe. Therefore, you have to keep cautious to prevent sending confidential files. However, sometimes, human errors are inevitable. So, in order to better block this, you can utilize the following VBA code to let Outlook warn you every time when you may attach potentially confidential files.
Get a Warning before Attaching Confidential Files to Your Outlook Email
- In the first place, launch your Outlook application.
- Then in main Outlook window, press “Alt + F11” key buttons.
- Next you will get access to Outlook VBA editor window successfully.
- Now you need to open the “ThisOutlookSession” project.
- Subsequently, copy and paste the following VBA codes into this project.
Public WithEvents objInspectors As Outlook.Inspectors Public WithEvents objMail As Outlook.MailItem Private Sub Application_Startup() Set objInspectors = Outlook.Application.Inspectors End Sub Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector) If Inspector.CurrentItem.Class = olMail Then Set objMail = Inspector.CurrentItem End If End Sub Private Sub objMail_AttachmentAdd(ByVal Attachment As Attachment) Dim strFile As String Dim objFileSystem As Object Dim strFilePath As String Dim objWordApp As Word.Application Dim objWordDocument As Word.Document Dim objSentence As Object Dim objWord As Object Dim strMsg As String Dim nResponse As Integer strFile = Attachment.DisplayName 'Here we take Word document and text file as an example If InStr(LCase(strFile), "docx") > 0 Or InStr(LCase(strFile), "doc") > 0 Or InStr(LCase(strFile), "txt") > 0 Then Set objFileSystem = CreateObject("Scripting.FileSystemObject") strFilePath = objFileSystem.GetSpecialFolder(2).Path & "\" & Format(Now, "dd-mm-yyyy-hh-mm-ss") & Attachment.DisplayName Attachment.SaveAsFile strFilePath Set objWordApp = CreateObject("Word.Application") Set objWordDocument = objWordApp.Documents.Open(strFilePath) objWordDocument.Activate For Each objSentence In objWordDocument.StoryRanges For Each objWord In objSentence.Words 'Check if contain specific words 'You can change the following line as per your actual needs If objWord.Text = "DataNumen" Or objWord.Text = "Confidential" Then strMsg = "The new attachment " & Chr(34) & Attachment.DisplayName & Chr(34) & " may contain confidential information. Are you sure to attach it?" nResponse = MsgBox(strMsg, vbExclamation + vbYesNo, "Check Confidential File") If nResponse = vbNo Then Attachment.Delete End If End If Exit For Next Next End If End Sub
- After that, you ought to sign this code.
- Later confirm your Outlook macro settings to permit signed VBA projects.
- Eventually you can restart your Outlook to activate the new macros.
- From now on, every time when you attach the files which meet the criteria of confidential files, you will get a waring like the screenshot below:
- If you select “Yes”, the file will be attached. If “No”, the file won’t be attached.
Avoid Miserable PST Problems
Since Outlook PST file is vulnerable, in order to prevent PST damage, you should make great efforts, such as backing up your Outlook PST files regularly, keeping a potent Outlook repair tool like DataNumen Outlook Repair. Therefore, you will be able to attempt PST data recovery either from backups or via the fix utility.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including damaged mdf and outlook repair software products. For more information visit www.datanumen.com
Leave a Reply