Search code examples
lotus-noteslotus-dominolotus-formula

Is there a Lotus view formula to find mails which were sent outside of the local domain?


Somehow my corporate email address has found its way onto a spam/phish list. I suppose it's unavoidable, but I can't think of any time that I've sent an email to an external address and I'm very curious to know how it could have 'escaped'.

I would like to create a SELECT formula to find any mails where one or more recipients are external (ie. do not end with '@mycompany.com', '@mycompany.com>' or '/MYCOMPANY/COM'.

I've used '@Contains' in other queries, but @Contains and @Ends don't really do the job here. If they returned a count of the number of matches, then I could compare it to the total number of recipients. Any mails where these totals are unequal will be the ones I'm looking for. But they only return booleans.


Solution

  • I would do it like this (do NOT mix MYDOMINODOMAIN with /MYCOMPANY/COM):

    _myDomains := @Lowercase("MYDOMINODOMAIN" : "mycompany.com" : "mycompany.net");
    _mailRecipientString := @LowerCase(@ReplaceSubstring(SendTo : CopyTo : BlindCopyTo : Recipients; @Char(13) : @Char(9) : @Char(34) : @Char(39) : "," : "<" : ">" : "\"" : " " ; " "));
    _mailRecipientValues := @Explode(@Implode(_mailRecipientString;" "); " "; @False);
    _mailDomains := @Unique(@Trim(@Explode(@Implode(@Word(_mailRecipientValues; "@"; 2); " "); " "; @False)));
    
    SELECT @Trim( @Replace( _mailDomains ; _myDomains ; "" ) ) != ""
    

    What does this formula do?

    Every address in SendTo, CopyTo, BlindcopyTo and (this is for paranoia as it contains the three former) Recipients ALWAYS has an @. I get the domains of this addresses using @Word.

    Then I replace the "good" domains in this list with an empty string (@Lowercase to be sure). If the result is something different than the empty string -> Found one