- Joined
- Jul 7, 2014
- Messages
- 1
- Reaction score
- 0
- Points
- 1
Hey all,
If this should be in the Developer area, I apologize.
I'm looking to get an AppleScript working that will accept Calendar invitations and add them to my Calendar as soon as they are received in mail. I've scoured the Google and cannot see any way to get this working.
Using different scripts I can get an event to show up in my Calendar, asking to be accepted. However, I need this to happen automatically. Invitation comes in via mail, Calendar grabs the attachment, sends an acceptance notification, and the time is marked as busy.
Hopefully someone here can point me in the right direction.
Cheers,
Jason
My current script (snagged from the net) is below:
If this should be in the Developer area, I apologize.
I'm looking to get an AppleScript working that will accept Calendar invitations and add them to my Calendar as soon as they are received in mail. I've scoured the Google and cannot see any way to get this working.
Using different scripts I can get an event to show up in my Calendar, asking to be accepted. However, I need this to happen automatically. Invitation comes in via mail, Calendar grabs the attachment, sends an acceptance notification, and the time is marked as busy.
Hopefully someone here can point me in the right direction.
Cheers,
Jason
My current script (snagged from the net) is below:
Code:
(*
Script for automatically extracting calendar items from meeting requests
and adding them into iCal.
*)
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
(* path to which to save the tmp file. This may need to be changed, AppleScript's handling of paths leaves much to be desired *)
set thePath to POSIX file "/tmp/tmp_invite.ics"
tell application "Mail"
repeat with theMessage in theMessages
set theSource to the source of theMessage
(* Find the range of the message source that is an ics message
Note: this works both on messages that detect the .ics attachement,
and on crappy Exchange invites that show up as an owa url. *)
set vcalBegin to the offset of "BEGIN:VCALENDAR" in theSource
set vcalEnd to (the offset of "END:VCALENDAR" in theSource) + (the length of "END:VCALENDAR")
(* Get the ics data *)
set theInvite to the rich text vcalBegin thru vcalEnd of theSource
(* Only deal with requests *)
if (the offset of "METHOD:REQUEST" in theInvite) is equal to 0 then
(* do nothing *)
else
(* write to a temp file *)
set fh to open for access thePath with write permission
write theInvite to fh as string
close access fh
(* open in iCal *)
tell application "Calendar" to open the thePath
(* delete the file *)
tell application "Finder" to delete the thePath
end if
end repeat
end tell
end perform mail action with messages
end using terms from