Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Apps and Programs
AppleScript: Auto-accept Calendar Invites
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="jsheil-benevity" data-source="post: 1591490" data-attributes="member: 328879"><p>Hey all,</p><p>If this should be in the Developer area, I apologize. </p><p></p><p>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.</p><p></p><p>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.</p><p></p><p>Hopefully someone here can point me in the right direction.</p><p></p><p>Cheers,</p><p>Jason</p><p></p><p>My current script <a href="http://hints.macworld.com/dlfiles/extract_ics_scpt.txt" target="_blank">(snagged from the net)</a> is below:</p><p>[CODE](*</p><p> Script for automatically extracting calendar items from meeting requests</p><p> and adding them into iCal.</p><p>*)</p><p></p><p></p><p>using terms from application "Mail"</p><p> </p><p> on perform mail action with messages theMessages for rule theRule</p><p> (* path to which to save the tmp file. This may need to be changed, AppleScript's handling of paths leaves much to be desired *)</p><p> set thePath to POSIX file "/tmp/tmp_invite.ics"</p><p> </p><p> tell application "Mail"</p><p> repeat with theMessage in theMessages</p><p> set theSource to the source of theMessage</p><p> (* Find the range of the message source that is an ics message </p><p> Note: this works both on messages that detect the .ics attachement,</p><p> and on crappy Exchange invites that show up as an owa url. *)</p><p> set vcalBegin to the offset of "BEGIN:VCALENDAR" in theSource</p><p> set vcalEnd to (the offset of "END:VCALENDAR" in theSource) + (the length of "END:VCALENDAR")</p><p> (* Get the ics data *)</p><p> set theInvite to the rich text vcalBegin thru vcalEnd of theSource</p><p> </p><p> (* Only deal with requests *)</p><p> if (the offset of "METHOD:REQUEST" in theInvite) is equal to 0 then</p><p> (* do nothing *)</p><p> else</p><p> (* write to a temp file *)</p><p> set fh to open for access thePath with write permission</p><p> write theInvite to fh as string</p><p> close access fh</p><p> </p><p> (* open in iCal *)</p><p> tell application "Calendar" to open the thePath</p><p> (* delete the file *)</p><p> tell application "Finder" to delete the thePath</p><p> </p><p> end if</p><p> </p><p> end repeat</p><p> end tell</p><p> end perform mail action with messages</p><p>end using terms from[/CODE]</p></blockquote><p></p>
[QUOTE="jsheil-benevity, post: 1591490, member: 328879"] 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 [URL="http://hints.macworld.com/dlfiles/extract_ics_scpt.txt"](snagged from the net)[/URL] 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[/CODE] [/QUOTE]
Verification
Name this item. 🍎
Post reply
Forums
Apple Computing Products:
macOS - Apps and Programs
AppleScript: Auto-accept Calendar Invites
Top