Jump to content
Server Maintenance This Week. ×

Cleaning up email addresses


This topic is 6705 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi, I spent about 2-3 hours puzzling out a calculation to take the "From:" header of an email message imported into Filemaker and clean it up so that ONLY the email address remains. It's useful when you need to make a relation that matches based on email address. Here it is. Comments or suggestions welcomed.

------Start Calculation---------

/* This calculation examines the From: header of an email message and cleans it, yielding JUST the email address. It removes full names with or without quotation marks and spaces in them, before or after the email address, and also removes quote marks and < > symbols. My purpose for the calculation is to facilitate clean relational matching between a table containing 1 email message per record, and a list of clients' email addresses. It also lowercases the email address for sake of consistency. */

/* copyright 2005 Gilbert Osmond, NO RESTRICTIONS on use, reproduction, sale, or incorporation into other code. */

Case (

/* If From: line contains no spaces, there's nothing fancy to do; just eliminate extra characters */

PatternCount (From; " ") = 0; Lower (Substitute (From; ["<"; ""] ; [">"; "" ] ; ["""; ""] ) ) ;

/* If From: line contains one or more spaces after the email address, eliminate everything following the email address. */

( Position (From ; " "; ( Position (From; "@"; 1; 1)); -1)) = 0 ;

Lower ( Substitute (

Left ( From;

(Position (From; " "; 1; 1))

)

; ["<"; ""] ; [">"; "" ] ; ["""; ""])

)

;

/* Otherwise, eliminate everything leading up to (before) the email address. */

Lower ( Substitute (

Right ( From;

(Length (From) -

(Position (From ; " ";

(Position (From; "@"; 1; 1));

-1))

)

)

; ["<"; ""] ; [">"; "" ] ; ["""; ""])

)

)

--------END CALCULATION

Edited by Guest
Link to comment
Share on other sites

or this:

Let([

field = theHeader;

pos@ = Position ( field ; "@" ; 1 ; 1 );

startEmail = Position ( field; "<" ; pos@ ; -1 ) +1;

endEmail = Position ( field ; ">" ; pos@ ; 1 )

];

Middle ( field ; startEmail ; endEmail - startEmail )

)

Link to comment
Share on other sites

Yeah, my bad. I had searched other forums (within FMforums.com) extensively last night for a solution, but failed to come across this complete & more comprehensive solution to the problem:

http://fmforums.com/forum/showtopic.php?tid/78240/post/80167/hxl/email/#80167

(Topic #78240 in this forum.)

It has a link to a handy demo file that easily and seamlessly converted to FP7/8 format; covers all bases.

Link to comment
Share on other sites

This topic is 6705 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.