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


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: 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 | # ]