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


Click here to return to the 'Use iCal to set a response reminder for a Mail message' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use iCal to set a response reminder for a Mail message
Authored by: mark hunte on Jun 30, '05 11:54:39AM
I have since updated the script to cope with more than one email at a time here it is below.

Thanks Rob for also pointing out the date format

(* A script to use with Mail to set a response event in iCal, select a message and then run the
script and follow the dialogs  - written by Mark Hunte 2005 *)

global theEvent
tell application "Mail"
	set theMessages to selection
	repeat with eachMessage in theMessages
		set theFrom to (sender of eachMessage)
		set Extract_Addr to extract address from theFrom
		set the_delim1 to do shell script "echo " & quoted form of theFrom & " " & " |awk -F\\< '{print $1}'"
		set theFrom to the_delim1
		set theSubject to ("Subject: " & (subject of eachMessage))
		set theSubject1 to (subject of eachMessage)
		try
			
			set theText to Extract_Addr & return & return & theSubject
			
		end try
		set iCalendars to {}
		
		set theCals to {}
		my _Ical(theFrom, theSubject, theSubject1, theText, iCalendars, theCals)
	end repeat
	
end tell


on _Ical(theFrom, theSubject, theSubject1, theText, iCalendars, theCals)
	tell application "iCal"
		set theCals to calendars whose writable is true
		repeat with i from 1 to count of theCals
			copy title of item i of theCals to end of iCalendars
			
		end repeat
	end tell
	
	tell application "Finder"
		
		
		set timestamp to current date
		set theday to (day of (current date)) as string
		
		
		set monthList to {January, February, March, April, May, June, July, August, September, October, November, December}
		repeat with i from 1 to 12
			if timestamp's month = item i of monthList then
				set theMonth to text -2 thru -1 of ("0" & i)
				exit repeat -- no point continuing once we have what we want
			end if
		end repeat
		
		set theyear to (year of (current date)) as string
		
		display dialog "Enter Date of the event for " & theFrom & ": i.e " & theday & "/" & theMonth & "/" & theyear default answer theday & "/" & theMonth & "/" & theyear
		
		set theSdate to the text returned of the result
		
		display dialog "Enter time of the event : (24 hour time)" default answer "12:00"
		
		set theTime to the text returned of the result
		
		display dialog "Enter ending time of event (24 hour time)" default answer "13:00"
		
		set theEtime to the text returned of the result
		
		display dialog "Number of Hours before event to sound alarm(blank for no alarm): " default answer "1"
		
		set theAlarmTime to the text returned of the result
		
		display dialog "Type of Response" buttons {"Email", "Call", "Meeting"} default button 3
		set the button_pressed to the button returned of the result
		
		if the button_pressed is "Email" then
			set button_pressed to "to ~ " & button_pressed & "  "
		else if the button_pressed is "Call" then
			set button_pressed to "to ~ " & button_pressed & "  "
		else
			set button_pressed to "for ~ " & button_pressed & " with  "
		end if
		display dialog "Any Action taken so far: " default answer " "
		
		set theActionTaken to the text returned of the result
		
		
		set theChoice to choose from list iCalendars with prompt "Choose the Calendar to use" OK button name "Choose" without multiple selections allowed and empty selection allowed
		
		if theChoice is not false then
			set theCalChoice to item 1 of theChoice
		end if
		
		set theCalName to theCalChoice
		
		
		
		set i to 1
		
		repeat with anitem in iCalendars
			if item i of iCalendars is equal to theCalName then
				set theNum to i
				exit repeat
			end if
			set i to i + 1
		end repeat
	end tell
	
	set currentCal to item theNum of theCals
	
	set theDate to date theSdate
	
	set theDate to date theTime of theDate
	
	set endDate to date theSdate
	
	set endDate to date theEtime of endDate
	
	
	tell application "iCal"
		
		set theEvent to (make event at end of events of currentCal with properties {start date:theDate, end date:endDate, summary:"Mail reminder " & button_pressed & return & theFrom & ". " & return & "About, " & theSubject1, description:"Reminder set on " & timestamp & return & "Any Action taken so far: " & return & theActionTaken & return & theText})
		if theAlarmTime is not "" then
			set theAlarm to (theAlarmTime as integer) * -60
			make new sound alarm at end of sound alarms of theEvent with properties {trigger interval:theAlarm}
		end if
		
	end tell
	
end _Ical

-- comment out below if you do not want ical to show you the last event.
tell application "iCal"
	activate
	show theEvent
end tell

---
mh

[ Reply to This | # ]

Use iCal to set a response reminder for a Mail message
Authored by: Sport73 on Jun 30, '05 12:53:38PM

Just wanted to say:

THANK YOU! THANK YOU! THANK YOU!

I've been looking for a way to do this for some time; this script is clean, simple and functional.



---
Productivity, Beauty, Capably Simplicity, Elegantly Powerful = MAC



[ Reply to This | # ]
Use iCal to set a response reminder for a Mail message
Authored by: roballen on Jun 30, '05 03:55:26PM

Thank you for this.

Something I have missed from outlook.

I've modified the script to automatically default to a purpose calendar, one less key click.

Would there be any way to have a dialogue box appear that asked all the questions at once?

Excellent script.



[ Reply to This | # ]
Use iCal to set a response reminder for a Mail message
Authored by: chjabu on Jun 30, '05 10:33:06PM

the script runs fine from the script menu, but not from a rule set up in Mail Act-On. Any one else having the same problem or have any suggestions? Thx.



[ Reply to This | # ]