I’m trying to create a script that will create events and todos from Mail messages. (I know there are some out there, but they don’t do quite what I want.) I can get the info I need from Mail, but have problems creating the iCal entry. I want to prompt the user to select a calendar and then create the event or todo on the selected calendar. The problem occurs after I get the selection from the user and try to make a new event/todo on that calendar. When I run this script, I get the error: “iCal got an error: Can’t make calendar {”@Anywhere"} into type reference."
I’ve tried all sorts of shennanigans to get this to work, but I’m afraid I’m missing what is probably a simple fundamental of AppleScript. I’d greatly appreciate if someone would have mercy on me and provide some advice.
Here’s the script:
tell application "Mail"
set selectedMsg to the selection
set countMsgs to (count selectedMsg)
if countMsgs is not equal to 1 then
display dialog "Choose one and only one message!" buttons {"Okay"}
return
end if
--set msgToProcess to item 1 of selectedMsgs
set taskSubject to subject of item 1 of selectedMsg
set taskNotes to content of item 1 of selectedMsg
end tell
tell application "iCal"
set allCalNames to name of every calendar
set chosenCalendar to (choose from list allCalNames)
tell calendar chosenCalendar
make new todo with properties {summary:taskSubject, description:taskNotes}
end tell
end tell
Thanks in advance.
- Leon