Capture incoming eMail, parse for coordinates, create GPX file

Hello fellow Maestros,

I am currently working on a workflow which will:

  • Collect the content (later: attachments too) of eMails
  • Scan the body of mails (and attachments) for coordinates and additional data
  • Create GPX coordinate files from that data, one file per coordinate/data set

I used an Apple Mail rule to identify the incoming mails, triggering KM via AppleScript once the rule matches.

First, it was easy capturing the mail body and subject with simple AppleScript lines into variables.
Now I am running into this problem: When multiple eMails arrive at once, the rule launches KM, but only ONE mail is processed.

What could I do to improve this? Ideas:

  • Determine the amount of incoming new eMails and repeat the parsing process per each mail
  • Have the macro trigger for each eMail (how? Is this possible?)
  • Identify unread eMails by finding the blue unread dot on screen and click them (yikes?!)

Anything else I can do?

I managed to write an AppleScript already which returns the number of unread eMails of an Inbox, but I am not sure wether I should continue down that road…