The simplest way that I have found so far is to set up a notification to be triggered using the Apple Find My Friends (not technically 3rd Party IMHO) which sends an email to my indigo email address. Using the email polling function or even the push notifications using IMAP have always proved to be far too slow in processing the emails and has meant that I have had to make the GeoFence extremely large to make the triggers worthwhile.
I have found that the quickest way to trigger any event using email is to setup a Rule in apple mail which writes the required information from the incoming email into a variable in Indigo and then using a variable change to trigger any actions. I have found that the response time is measured in a few seconds from the point the email is received and this is adequate for my needs.
The following applescript is triggered when incoming mail meets certain criteria based on selected sender information-
- Code: Select all
using terms from application "Mail"
on perform mail action with messages these_Messages for rule theRule
tell application "Mail"
delay 1 -- this delay is included otherwise the script seems to process the previously received email and not the latest one.
set this_subject to subject of item 1 of these_Messages
set this_date to date received of item 1 of these_Messages
end tell
tell application "IndigoServer"
set value of variable "messageLast" to this_subject
set value of variable "messageCounter" to (value of variable "messageCounter") + 1 -- I have a message counter which resets every day to check that all emails have been processed
set value of variable named "messageLastTime" to this_date as string
end tell
end perform mail action with messages
end using terms from
Ideally I would prefer Find My Friends to send a notification to my Mac Mini (which is instantaneous) but haven't investigated this further as the method above is adequate for my needs.
Hope somebody else finds this useful
JIA
PS The additional information that can easily be extracted from the emails is as follows -
id (integer, r/o) : The unique identifier of the message.
all headers (text, r/o) : All the headers of the message
background color (blue/gray/green/none/orange/other/purple/red/yellow) : The background color of the message
mailbox (mailbox) : The mailbox in which this message is filed
content (rich text, r/o) : Contents of an email message
date received (date, r/o) : The date a message was received
date sent (date, r/o) : The date a message was sent
deleted status (boolean) : Indicates whether the message is deleted or not
flagged status (boolean) : Indicates whether the message is flagged or not
flag index (integer) : The flag on the message, or -1 if the message is not flagged
junk mail status (boolean) : Indicates whether the message has been marked junk or evaluated to be junk by the junk mail filter.
read status (boolean) : Indicates whether the message is read or not
message id (text, r/o) : The unique message ID string
source (text, r/o) : Raw source of the message
reply to (text, r/o) : The address that replies should be sent to
message size (integer, r/o) : The size (in bytes) of a message
sender (text, r/o) : The sender of the message
subject (text, r/o) : The subject of the message
was forwarded (boolean, r/o) : Indicates whether the message was forwarded or not
was redirected (boolean, r/o) : Indicates whether the message was redirected or not
was replied to (boolean, r/o) : Indicates whether the message was replied to or not