Make AppleScript rule in Mail.app to add date in subject to Reminders

Hi, I’m brand new to AppleScript, but anxious to learn. I’ve been programming custom macros in VBA for years, and while it’s a different syntax, I’m hoping I can pick this up quick. I am looking for an AppleScript rule to use in the Mail.app to look extract a date from the subject (or body if simpler), and automatically add into the Reminders.app.

Thank you,
Scott

Model: MacBook Pro, mid-2010
AppleScript: 2.5.1
Browser: Mozilla/5.0 (000000000; 00000 000 00 0 000000) DDDDDDDDDDDDDDDDDDDD DDDDDDD DDDD DDDDDD DDDDDDDDDDDDD DDDDDDDDDDDDDDD
Operating System: Mac OS X (10.8)

Hi,

the following script isn’t completed, because I don’t know the exact form of the date string in the subject.
You have to add the code in this line


return (current date) -- add the code depending on the date string syntax to create an AppleScript date

replace the index 1 in “tell list 1” with the appropriate index of the reminder list or with its name
as a literal double quoted string


using terms from application "Mail"
	on perform mail action with messages theMessages
		repeat with aMessage in theMessages
			set messageSubject to subject of aMessage
			set dueDate to my extractDateFromSubject(messageSubject)
			my addReminder(dueDate)
		end repeat
	end perform mail action with messages
end using terms from

on extractDateFromSubject(subject)
	return (current date) -- add the code depending on the date string syntax
end extractDateFromSubject

on addReminder(dueDate)
	tell application "Reminders"
		tell list 1
			make new reminder with properties {due date:dueDate, name:"New Reminder"}
		end tell
	end tell
end addReminder

put the script into ~/Library/Application Scripts/com.apple.mail
create a rule in Mail.app, choose the run AppleScript action and select the script from the popup menu

Thanks for that. I just saw that I had a post, so please forgive the lateness of my reply.

If I do this with iCal instead of reminders, is there a way I can set options such as reminder times and open a file?

Thanks,
Scott