[X4U] Extracting data from an email

Simon Forster simon-lists at ldml.com
Sun Jul 18 01:09:39 PDT 2010

On 17 Jul 2010, at 17:14, Andy wrote:

> I want to extract some data from emails sent from a shopping cart. The data will be something like Product: xxxx
> Order No: xxxx, Name: xxxx, Address: xxxx etc.
> The emails will arrive as either html or plain text. I want to be able to automatically extract this data and insert it into a Filemaker database.
> I know I can run a script from a Rule in Mail or Entourage to save/export the emails as plain text but how to get the data into a form that Filemaker can use?
> Or is there some other way of doing this? 
> Any help from you guys would be really appreciated.

There's a number of ways to do this - depending on volumes, whether the order data needs to be matched up with other data in FileMaker, how automated you need the process to be, etc.

I'm guessing that there wont be too many entries? Probably you could parse out the data and add it into FileMaker all via AppleScript. Personally I tend to add in a bit of perl via AppleScript's do shell script step as I understand regular expressions and find that mechanism easier - but if you need regular expressions and don't want to go with perl, check out the Satimage extension <http://www.satimage.fr/software/en/downloads/downloads_companion_osaxen.html>.

However, I'm reasonably confident that you'll be able to get away with using plain old AppleScript.

Go to the AppleScript users list for more info on using AppleScript <http://lists.apple.com/mailman/listinfo/applescript-users>.

Split the process into a couple of stages:

- Get the email
- Parse out the bits you want
- Add to FileMaker

Each stage can be developed and debugged on its own before stitching together to get it to work as you want.

As a tip, if you're using Apple's Mail application, you can fire a rule to run an AppleScript. For instance I have a rule which identifies certain incoming emails and drops them straight into my "To Do" application. Handy when I'm out and about and suddenly think of something - I just send myself an email and it's in the list next time I check.



More information about the X4U mailing list