Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pinguthepenguin

macrumors newbie
Original poster
Jan 26, 2008
16
0
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?
 
Thanks for the reply, however rules are not appropriate here as the trigger is not receiving an email.
 
You could still potentially use a mail rule in combination with automator, if you do it as a dead-man switch. The idea is that you have a timer that counts down. When the timer reaches zero, an event happens (your follow-up email). To prevent this event, you reset the timer to its starting value frequently (whenever you DO receive your specific email).

I don't really use Automator or mail rules much so you'll need to adapt this idea to fit what the programs can do for you.
  1. Every time you DO receive the email, use automator/mail rule to write the time or copy the email to a folder.
  2. Automator checks the folder for most recent time or the date of files and if the date is larger than one week, send the follow-up email
  3. After sending the new email, optionally write a placeholder file or time to your target folder so that you don't get spammed with reminder emails every time the script runs.

Automator will need to run its script periodically for this. You can also use the built-in chron system to schedule automator (or a perl/ruby/python/applescript) to do the task.
 
I really appreciate the reply MasConejos. I should have been more specific with my original question, apologies, however it is not the trigger mechanism that is causing me difficulties.

This is my scenario. At the end of every week I am sent email summaries from my team. Invariably they are late or forgotten. I would like to save myself time in chasing them by having an automator application I can run that will query who has sent me an update this week, and then automatically email those who have forgotton.

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.
 
I am fairly certain this could be accomplished with applescript, but I'm not at a mac so I can't experiment right now. I'll try to remember to look into it this this evening, but no promises
 
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.

Unfortunately a smart mail box is not accessible by AppleScript or Automator.
You can try this script example by selecting all messages in your smart mail box and run it from the ScriptEditor.


Code:
-- 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
 
Last edited:
Thanks kryten2, I am almost there. Can I bypass the smart mail box restriction, and add that logic to the script?

I would need to check messages in the past five days that have "summary" or "update" in the subject.
 
You can use a filter. Here's a simple example :


Code:
-- 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
 
Great. Glad to hear it worked. When you enable the Show Script menu in menu bar option from the ScriptEditor Preferences window, you can save it in your Mail Scripts Folder so it's available from the Script Menu in Mail.
 

Attachments

  • Screen Shot 2015-03-01 at 20.40.11.png
    Screen Shot 2015-03-01 at 20.40.11.png
    83.4 KB · Views: 264
  • Screen Shot 2015-03-01 at 20.41.08.png
    Screen Shot 2015-03-01 at 20.41.08.png
    16.8 KB · Views: 321
  • Screen Shot 2015-03-01 at 20.42.57.png
    Screen Shot 2015-03-01 at 20.42.57.png
    10.7 KB · Views: 241
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.