shrydvd
New Member
- Outlook version
- Outlook 2019 64-bit
- Email Account
- IMAP
The following code will warn the user that they may have sensitive information in the body of their email. However, sometimes that body may be quite long and it's not easy to see what the code is referring to when it gives the message. I am wanting to add to this code something that will highlight the matched strings in the body. I would imagine it will be something like "for each matched string, .highlight=true? or something like that.
Thank you,
Thank you,
Code:
Dim myMailToSend As MailItem
Dim re As Object
Const sPat As String = "\b\d{3}[\D]\d{2}[\D]\d{4}\b|\b\d{9}|\b\d{2}[\D]\d{7}\b"
Set myMailToSend = Item
Set re = CreateObject("vbscript.regexp")
re.Pattern = sPat
s = myMailToSend.Body & " " & myMailToSend.Subject
If re.Test(s) = True Then
strMsg = "This email appears to contain sensitive information." & _
"Do you still want to send it?"
nResponse = MsgBox(strMsg, vbExclamation + vbYesNo + vbDefaultButton2, _
"Check Sensitive Information")
If nResponse = vbYes Then
Cancel = False
Else
Cancel = True
Exit Sub
End If
End If