Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Automatically import Exchange events from Mail into iCal Apps
My company uses Exchange as our mail and calendaring backend, and we rely heavily on Exchange - Outlook -Entourage's ability to send meeting notifications to invitees. I hate Entourage, so I use Apple's Mail and iCal. The only problem is that meeting invites do not always get parsed properly by Mail.

Sometimes they show up as standard .ics files that I can double click to have them imported into iCal. Other times they show up as links to somewhere on the OWA (Outlook Web Access) server that don't resolve. Inspecting the email as raw source shows that the ICS data is actually in the email, it just isn't showing up right. So I wrote an AppleScript that will extract ICS data from an email, save it to a temp file, import it into iCal, then remove the temp file.

I set this script as the action for a Mail rule of the form:
Content-class -- Contains  -- urn:content-classes:calendarmessage
Note that the Content-class header is not in the default list of headers on which you can set a rule action, but you can add it.

Now whenever I receive a meeting invite generated by Outlook or Entourage (though not Evolution, which apparently doesn't set this header), the script is automatically run and the event is added to my iCal schedule.

[robg adds: I haven't tested this one.]
    •    
  • Currently 3.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[40,452 views]  

Automatically import Exchange events from Mail into iCal | 9 comments | Create New Account
Click here to return to the 'Automatically import Exchange events from Mail into iCal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically import Exchange events from Mail into iCal
Authored by: Brooks on Aug 23, '06 08:29:30AM

You can also use previous alternative and next alternative (under View > Message in Mail.app) to turn the link to OWA into an invite that will import into iCal and vice versa.

The hot-key for previous alternative is command [ and the hot-key for next alternative is command ]



[ Reply to This | # ]
Automatically import Exchange events from Mail into iCal
Authored by: jaaronp on Aug 23, '06 09:07:00AM

Wow. I tore my hair out over this for months and never even considered that. Good to know.



[ Reply to This | # ]
Automatically import Exchange events from Mail into iCal
Authored by: Brooks on Aug 23, '06 09:10:06AM

I did the same thing...

It seems Apple could do a better job of letting people know of the next and previous alternative functionality because in a "mixed platform work environment" it is absolutely necessary for me.



[ Reply to This | # ]
Automatically import Exchange events from Mail into iCal
Authored by: jaaronp on Aug 23, '06 09:26:16AM
In fact I can guarantee that the script as posted does not work.
The bit that reads:

set thePath to POSIX file "/tmp/tmp_invite.ics"

should actually be:

set thePath to "harddrive_name:path:to:somewhere:good"

Where "harddrive_name:path:to:somewhere:good" is a valid path (starting with the name of your harddrive). I introduced this bug when trying to make the script generic enough to post.
Does anyone know a good real way to specify a path without knowing the name of the root volume?

[ Reply to This | # ]
Automatically import Exchange events from Mail into iCal
Authored by: tforrest on Aug 23, '06 10:12:48AM
try this:
set thePath to (((path to temporary items folder from user domain) as string) & "temp_invite.ics") as string

[ Reply to This | # ]
Automatically import Exchange events from Mail into iCal
Authored by: MalteMarquarding on Aug 20, '07 10:33:42PM
Hi,

Thanks for this script. It makes ife a lot easier.

Here is the modified version which works.


(*
	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
		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 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
					(* 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 "/tmp/temp_invite.ics" as POSIX file
					
					(* write to a temp file *)
					set theTmpfile to open for access thePath with write permission
					set eof theTmpfile to 0
					set theDummy to theInvite as text
					write theDummy & return to theTmpfile
					close access theTmpfile
					(* open in iCal *)
					tell application "iCal" 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



[ Reply to This | # ]
Automatically import Exchange events from Mail into iCal
Authored by: thespider on Feb 04, '08 08:25:13AM

Does anyone know of a way to modify the script to enter into a different calendar?



[ Reply to This | # ]
Automatically import Exchange events from Mail into iCal
Authored by: Schwie on Apr 12, '08 11:58:40PM
This script worked like a champ for me in Leopard, but I had to tweak the Rule in Mail.app which may be exclusive to my company's Exchange server. Here's what I did:

After I added the custom header as the original hint instructed, the script wasn't working for me. So, I peaked at the long header for the messages I wanted to parse and I found the matching criteria were a little different than the original hint. Instead of using "urn:content-classes:calendarmessage" I had to use "urn:content-classes:appointment".

I pulled in over 600 calendar entries in maybe a minute on a little MBA 1.8. Nice. Very nice. Thanks for the hint!!!

[ Reply to This | # ]

Automatically import Exchange events from Mail into iCal
Authored by: Grabthor on Dec 09, '08 10:02:14AM

can anybody modify this to pull the ICS file out of a entourage email and import it into ICal? I just started looking at applescript today and have a very limited knowledge of how it works. Total scripting n00b that needs a hand. thank you very much



[ Reply to This | # ]