I would like to send an automated email every week conditional on whether a specific email has been received that week. Is this possible with the Automator tool, and if so, how can it be achieved please?
I have a smart mail box in mail that collects the relevant emails from the past week. What I can't do is interrogate this folder to see who is missing.
I hope that clarifies things, I was trying to keep my original question as generic as possible so it could benefit others, but in the process I did not provide sufficient detail, sorry.
-- Fill the list with the names and addresses of your team!!!
-- These are just examples.
set teamNamesList to {"John Doe <john.doe@hotmail.com>", "Jane Doe <jane.doe@hotmail.com>"}
tell application "Mail"
set selectedMessages to selection
if (count of selectedMessages) is equal to 0 then
display alert "No Messages Selected" message "Select the messages you want to process before running this script."
else
set senderList to {}
repeat with i from 1 to number of items in selectedMessages
set thisMessage to item i of selectedMessages
set senderItem to sender of thisMessage
if senderItem is not in senderList then
set end of senderList to senderItem
end if
end repeat
end if
end tell
repeat with j from 1 to number of items in teamNamesList
set this_item to item j of teamNamesList
if this_item is not in senderList then
sendReminderMessage(this_item)
end if
end repeat
on sendReminderMessage(fullySpecifiedEmailAddress)
tell application "Mail"
set theMsg to (make new outgoing message with properties {subject:"Reminder", content:"I haven't received your ...", visible:true})
tell theMsg
make new to recipient with properties {name:extract name from fullySpecifiedEmailAddress, address:extract address from fullySpecifiedEmailAddress}
end tell
--send theMsg -- Uncomment if you want to send the message
end tell
end sendReminderMessage
-- Fill the list with the names and addresses of your team!!!
-- These are just examples.
set teamNamesList to {"John Doe <john.doe@hotmail.com>", "Jane Doe <jane.doe@hotmail.com>"}
set daysToCheck to 5
set dateReference to (current date) - (daysToCheck * days)
tell application "Mail"
-- Change mailbox and account to your mailbox and account
set senderList to get sender of every message of mailbox "INBOX" of account "FOO" whose (subject contains "update" or subject contains "summary") and date received ≥ dateReference
end tell
repeat with j from 1 to number of items in teamNamesList
set this_item to item j of teamNamesList
if this_item is not in senderList then
sendReminderMessage(this_item)
end if
end repeat
on sendReminderMessage(fullySpecifiedEmailAddress)
tell application "Mail"
set theMsg to (make new outgoing message with properties {subject:"Reminder", content:"I haven't received your ...", visible:true})
tell theMsg
make new to recipient with properties {name:extract name from fullySpecifiedEmailAddress, address:extract address from fullySpecifiedEmailAddress}
end tell
--send theMsg -- Uncomment if you want to send the message
end tell
end sendReminderMessage