Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create Outlook-like reminders for Mail ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create Outlook-like reminders for Mail
Authored by: prachigauriar on Sep 11, '12 09:59:11AM

I am by no means an Automator or Applescript expert, but the Applescript below can be used with Automator to create reminders for each selected Mail message. Create an Automator workflow whose first item is Get Selected Mail Messages and whose second is Run Applescript with the script below.

The reminders are set to go into the “Follow-Ups” list with a reminder date of 9am the next day. If you want different values, it should be fairly obvious what to change in the script.

on run {input, parameters}
	set the_reminders to {}
	
	repeat with the_message in input
		tell application "Mail"
			-- If the subject starts with any number of "Re:" or "Fwd:", remove them
			set the_subject to do shell script "echo '" & the_message's subject & "' | sed -E -e 's/^((Re|Fwd): )*//g'
			set the_name to "Re: " & the_subject
			set the_body to "message://%3c" & the_message's message id & "%3e"
		end tell
		
		tell application "Reminders"
			tell list "Follow-Ups"
				-- Set the date to 9am tomorrow
				set reminder_date to (current date) + 1 * days
				set time of reminder_date to 60 * 60 * 9
				
				set the_reminder to (make new reminder with properties {name:the_name, body:the_body, remind me date:reminder_date})
				set end of the_reminders to the_reminder
			end tell
		end tell
	end repeat
	return the_reminders
end run

The script returns a list of the reminders that were created, which could then be passed to your next Automator action.

Edited on Sep 11, '12 10:22:42AM by prachigauriar


[ Reply to This | # ]
Create Outlook-like reminders for Mail
Authored by: drm0223 on Sep 15, '12 01:11:22PM

The work flow doesn't work, as it appears.

A '"' is needed a the end of the line starting
set the_subject to do shell script ...

The statements
tell list "Follow-ups"
end tell
are not needed and generate errors.

With these two changes, I got it to work! Thanks for the idea!



[ Reply to This | # ]
Create Outlook-like reminders for Mail
Authored by: prachigauriar on Sep 17, '12 07:56:57AM
Right, I forgot a close " on the sed command. If you update it as follows, things will work.

on run {input, parameters}
	set the_reminders to {}
	
	repeat with the_message in input
		tell application "Mail"
			-- If the subject starts with any number of "Re:" or "Fwd:", remove them
			set the_subject to do shell script "echo '" & the_message's subject & "' | sed -E -e 's/^((Re|Fwd): )*//g'"
			set the_name to "Re: " & the_subject
			set the_body to "message://%3c" & the_message's message id & "%3e"
		end tell
		
		tell application "Reminders"
			tell list "Follow-Ups"
				-- Set the date to 9am tomorrow
				set reminder_date to (current date) + 1 * days
				set time of reminder_date to 60 * 60 * 9
				
				set the_reminder to (make new reminder with properties {name:the_name, body:the_body, remind me date:reminder_date})
				set end of the_reminders to the_reminder
			end tell
		end tell
	end repeat
	return the_reminders
end run
As for the tell list "Follow-Ups" thing, that adds it to a specific list named "Follow-Ups". If you remove the tell block, it’ll probably just add it to the default (or currently selected) list of reminders.
Edited on Sep 17, '12 08:00:15AM by prachigauriar


[ Reply to This | # ]