using terms from application "Mail"
on perform mail action with messages messageList
tell application "Mail"
repeat with a from 1 to count of the messageList
set msgId to (message id of item a of messageList)
set msgUrl to "message:<" & msgId & ">"
set fromMsg to (sender of item a of messageList as string)
set subjMsg to (subject of item a of messageList as string)
set todoMsg to fromMsg & subjMsg
tell application "iCal"
tell calendar "Mail To Do"
set theDueDate to (current date) + 5 * days
make new todo at end with properties {summary:todoMsg, due date:theDueDate, priority:high priority, url:msgUrl}
end tell
end tell
end repeat
(*tell application "iCal"
delay 60
quit "iCal"*)
end tell
end perform mail action with messages
end using terms from
(*tell application "iCal"
delay 60
quit
end tell*)