07-07-2014, 11:17 AM #1
AppleScript: Auto-accept Calendar Invites
- Member Since
- Jul 07, 2014
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.
My current script (snagged from the net) is below:
(* 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
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By tdcallais in forum iOS and AppsReplies: 0Last Post: 07-06-2012, 02:47 PM
By andreiturcu in forum iOS and AppsReplies: 2Last Post: 11-04-2011, 07:47 AM
By georgemeek in forum OS X - Apps and GamesReplies: 0Last Post: 07-08-2010, 01:50 PM
By Kyle-wdp in forum iOS and AppsReplies: 2Last Post: 07-12-2009, 02:06 PM
By mjconn in forum iOS and AppsReplies: 0Last Post: 10-19-2008, 03:27 PM