Example (actual received) From: "Lexie" <EdwardWhite@smolka.sk>
The pattern is the name in quotation marks is always a first name and is different from the first name in the email address AND the email address ALWAYS consists of capitalized letters in the first and last name AT whateverdomain.tld.
This is readily apparent to the human eye but if scripted could result in false positives, so at first I just want to test it by just sending myself a message containing the from address every time it hits global rule if From (regex) ^.*((([A-Z][a-z]+)([A-Z][a-z]+))(?=@)).*$
MY PROBLEM is that in testing the regex matching part of the script, the first name of the email address contains the first few letters of the last name.
Pieced together from Soren's scripts...
Code: Select all
Function oLookup(strRegEx, strMatch, bGlobal) If strRegEx = "" Then strRegEx = StrReverse(strMatch) With CreateObject("VBScript.RegExp") .Pattern = strRegEx .Global = bGlobal .MultiLine = True .IgnoreCase = True Set oLookup = .Execute(strMatch) End With End Function ' Example: ' "Lexie" <EdwardWhite@smolka.sk> ' (([A-Z][a-z]+)(?=(\"\s\<|\"\<))) finds Lexie ' (([A-Z][a-z]+)(?=([A-Z][a-z]+\@))) finds Edward oMessage_From = """Lexie"" <EdwardWhite@smolka.sk>" Dim strRegEx, Match, Matches Dim o_name, o_emailname, sMSG ' find first name outside of <> strRegEx = "(([A-Z][a-z]+)(?=(\""\s\<|\""\<)))" Set Matches = oLookup( strRegEx, oMessage_From, False ) For Each Match In Matches o_name = Match.Value Next wscript.echo o_name ' find first name inside <> strRegEx = "(([A-Z][a-z]+)(?=([A-Z][a-z]+\@)))" Set Matches = oLookup( strRegEx, oMessage_From, False ) For Each Match In Matches o_emailname = Match.Value Next wscript.echo o_emailname If (o_name = o_emailname) Then sMSG = "Hit on name mismatch. Check spam for " & oMessage_From Else sMSG = "No match" End If wscript.echo sMSG