If your company has an exact policy that you shouldn’t send emails to the persons outside your company, you can use the way introduced in this article. It’ll teach you how to use VBA to get a warning if an email is sent to outside your company.
Sometimes, in order to protect data security, your company may demand you that when using business email account, you should only send emails to the persons inside your company. In other words, you aren’t permitted to send emails to the persons outside company, namely email addresses in external domains. However, perhaps at times you are a bit forgettable. In this case, you may wish that Outlook can automatically warn you when you send emails to outside company. Here we will focus on this issue and guide you how to achieve it via Outlook VBA.
Get a Warning When Sending Emails to the Persons outside Your Company
- In the first place, start your Outlook program.
- Then press “Alt + F11” key shortcuts.
- Next you will get access to Outlook VBA editor window.
- Subsequently, open the “ThisOutlookSession” project.
- Then copy and paste the following VBA codes into this project window.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim objMail As Outlook.MailItem Dim objRecipients As Outlook.Recipients Dim i As Long Dim strRecipientAddress As String Dim strPrompt As String Dim nWarning As Integer If TypeOf Item Is MailItem Then Set objMail = Item Set objRecipients = objMail.Recipients For i = objRecipients.Count To 1 Step -1 strRecipientAddress = objRecipients.Item(i).Address 'Change @datanumen.com to your own company domain If InStr(LCase(strRecipientAddress), "@datanumen.com") <= 0 Then Exit For Else Cancel = False End If Next i If InStr(LCase(strRecipientAddress), "@datanumen.com") <= 0 Then strPrompt = "Are you sure to send this email to outside your company? " nWarning = MsgBox(strPrompt, vbYesNo + vbQuestion, "Confirm Email to Outside Organization") If nWarning = vbNo Then Cancel = True End If End If End If End Sub
- After that, you should sign this code.
- Later change your Outlook macro settings to allow the signed macros.
- Finally, from now on, every time when you intend to send emails to the email addresses which are not in your company domain, you will receive a warning like the following screenshot:
Keep Closing Your Outlook Properly
Outlook tends to crash if you frequently close your Outlook improperly, such as forcing it to close due to sudden power outages. Every time your Outlook crashes, your PST file will suffer too. Once your PST file gets compromised, you will spend much more efforts to get back the damaged Outlook data than daily protection. In that case, the scanpst.exe will not be a lot help. You have no choice but to recur to a more potent tool, such as DataNumen Outlook Repair.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including SQL Server fix and outlook repair software products. For more information visit www.datanumen.com
Muchas gracias. ?Como puedo iniciar sesion?