Ignore hyperlink from being flagged as false pattern

LockonZero

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
I have a script that checks my outgoing email for any credit card number that are unmasked. However, if an embedded hyperlink coincidentally have the same format with the credit cards format that I am trying to filter, it flags it down and prevents me from sending the email. I want it to be able to determine if the pattern is within a hyperlink or not and perform its check before sending the email. Can someone advice on how I go about this? Am just a newbie with outlook vba so any help will be much appreciated. I'm attaching my script here.
 

Attachments

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You could check the character before and after the found code - if its not an EOL, space, or period, its more likely a url. You can do it using regex, not sure you can do it using like.

You could try adding a space after the last number in the array - but that only works if it is in the middle of a sentence but could cut down on the number of false alarms. I would probably do another IF statement if there is a match to the number string - the second one will check for a space before or after (4 in the array).
 

LockonZero

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Thanks for the tip Diane. Will try your suggestion.
 

LockonZero

Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
You could check the character before and after the found code - if its not an EOL, space, or period, its more likely a url. You can do it using regex, not sure you can do it using like.

You could try adding a space after the last number in the array - but that only works if it is in the middle of a sentence but could cut down on the number of false alarms. I would probably do another IF statement if there is a match to the number string - the second one will check for a space before or after (4 in the array).

Hi Dianne,

I've changed the pattern checking using regex instead of like and have something like this and is working.


With Reg1
.pattern = "(\d{16}|\d{4}-\d{4}-\d{4}-\d{4}|\d{4}.\d{4}.\d{4}.\d{4}|\d{4} \d{4} \d{4} \d{4})"
.Global = True
End With

However, I did find that if there is a pattern that matches 16 digits and there are other subsequent digits, it still flags instead of allowing it to be sent. sample is 11112222333344445555.
 

Similar threads

Top