New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Apps and Games Discussion of applications and games available for Mac OS X.

AppleScript: Auto-accept Calendar Invites


Post Reply New Thread Subscribe

 
Thread Tools
jsheil-benevity

 
Member Since: Jul 07, 2014
Posts: 1
jsheil-benevity is on a distinguished road

jsheil-benevity is offline
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:
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
QUOTE Thanks

Post Reply New Thread Subscribe


« iTunes - install earlier ver | XLSX files with Numbers »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

All times are GMT -4. The time now is 03:14 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?