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

A script to easily add Outlook invites to iCal Apps
Obnoxiously enough, Mail and iCal do not interoperate well with iCalendar invites sent through Outlook. There are several problems. First, Mail doesn't know what to do with the request... it simply lists the thing as "mime-attachment", and associates no application with it. Second, there are some elements of the MS format that iCal doesn't deal with properly.

I needed an easy solution to this problem. That is, if someone uses Outlook to send a meeting request, I need to be able to bring it up in iCal with one simple action. I first tried some AppleScript-based solutions, but they all had limitations.

My solution uses some Unix shell scripting. It allows you to open up Outlook requests simply by dragging the "mime-attachment" to the desktop. First, open up Terminal, and run the command:
 % mkdir ~/bin
Then put the following text into a file called ~/bin/ical_convert:
#!/bin/bash

cd "/Users/viega/Desktop/"
item=mime-attachment

while "true"; do
if [[ -e $item ]]; then
sed "s/ORGANIZER\:MAILTO\:.*/&xxxFRED&/" $item |
sed "s/xxxFREDORGANIZER//" | sed "s/ORGANIZER\:/ORGANIZER\;CN\=/" |
sed "s/CN\=MAILTO\:/CN\=/"> /tmp/iCal.ics
rm $item
open /tmp/iCal.ics
fi
sleep 1
done
Note that the line starting with "#!" needs to be the first line of the file, and that the "sed" line has been shown on three lines. Enter it as one continuous line with a space replacing each shown line break.

Next, run the commands:
 % chmod +x ~/bin/ical_convert
% ~/bin/ical_convert &
The ampersand causes the program to start running, while allowing you to type more commands. Now, you can just drag the attachment to the Desktop, and everything else will happen automatically.

The big issue is that you have to start up ~/bin/ical_convert every time you reboot the computer. One might put a little launcher program into StartupItems (just be sure to ensure the program isn't already running). I personally use the bash shell, and insert the following code into my .profile:
progname=ical_convert

if [[ `ps -auwwwx | grep $progname | grep -v grep` ]]; then
echo "Ical converter script already running."
else
echo "Starting ical conversion script."
~/bin/ical_convert&
fi
You could do a more precise check by dropping a PID into a well-known file and checking that, but whatever.

Another issue is that you should avoid putting files named "mime-attachment" onto your desktop unless you want them to be processed by iCal and deleted. If that bugs you, you could create a folder somewhere else, and change the magic path to point to that folder instead of the desktop. I personally prefer the ease of use of not having to hit a small target when I drag and drop.
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[15,511 views]  

A script to easily add Outlook invites to iCal | 14 comments | Create New Account
Click here to return to the 'A script to easily add Outlook invites to iCal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Actually...
Authored by: viega on Sep 12, '02 12:01:27PM

The editor added, "...that the "sed" line has been shown on three lines. Enter it as one continuous line with a space replacing each shown line break."

You don't actually need to do that in this case... seprate lines are fine :)



[ Reply to This | # ]
fred error
Authored by: matx on Sep 12, '02 01:18:31PM

[localhost:~/bin] matx% /Users/matx/bin/ical_convert: s/xxxFREDORGANIZER//: No such file or directory
/Users/matx/bin/ical_convert: s/CN\=MAILTO\:/CN\=/: No such file or directory



[ Reply to This | # ]
fred error
Authored by: viega on Sep 12, '02 02:55:55PM

I don't understand what you typed. You can't leave off the "sed" stuff, but you can separate things out onto three lines (that is, you can simply cut and paste).



[ Reply to This | # ]
fred error
Authored by: matx on Sep 12, '02 06:07:59PM

the problem was with the way the sed got all moved into one line...

using the script as originally submitted with the path to desktop changed it works fine (thanks!) and it didn't work when i moved the 3 sed commands to one line.



[ Reply to This | # ]
fred error
Authored by: viega on Sep 12, '02 06:28:47PM

Glad it works for you. It should work if they're all on one line, as long as the bars are still there ("|"). The editor added his comment, because the original submission I made DID have it all on one line, and there are ways you could break it up onto multiple lines where it wouldn't work :)



[ Reply to This | # ]
Whoops
Authored by: viega on Sep 12, '02 12:04:09PM

I forgot to change something before submitting. Change the line:

cd "/Users/viega/Desktop/"

To:

cd ~/Desktop/



[ Reply to This | # ]
Whoops
Authored by: viega on Sep 12, '02 12:24:00PM

I forgot to change something before submitting. Change the line:

cd "/Users/viega/Desktop/"

To:

cd ~/Desktop/



[ Reply to This | # ]
AppleScript better
Authored by: alex_kac on Sep 12, '02 01:13:10PM

Something that I think will be more useful to Mac heads is a FolderAction.

Now I\'m not good at AppleScript, but I know AS can do this natively as well as run shell scripts.

So possible if someone can write an AppleScript, we can attach it to a Folder as a FolderAction and voila.



[ Reply to This | # ]
AppleScript is NOT better
Authored by: viega on Sep 12, '02 02:28:11PM

No, the first thing I did was a folder action. They were too flakey. The actions kept disappearing mysteriously, first of all. Second, you couldn't drag-and-drop the mime-attachment to the folder directly because the mime-attachment was a read-only file. Third, you couldn't set the desktop to have folder actions and have that actually work. Fourth, even if actions worked robustly, while you can add Folder Actions to StartupItems, it was not straightforward to attach the folder action on login automatically. Fifth, Doing the regular expression replaces in AppleScript was going to be really messy, whereas it's simple from a shell script. The shell script also brought the entry up into iCal MUCH faster than the AppleScript solution.



[ Reply to This | # ]
AppleScript better
Authored by: viega on Sep 12, '02 02:33:46PM

By the way, here's the final AppleScript I was using as a folder action. The action disappeared on a fairly regular basis. All this script does is call out to the shell command.

But, if you can get it to work for you, that's great:

property this_command : "/Users/viega/bin/ical_convert"

on adding folder items to this_folder after receiving these_items
try
set this_result to do shell script this_command
on error error_message
display dialog error_message
end try
end adding folder items to



[ Reply to This | # ]
Which Outlook?
Authored by: alajuela on Sep 12, '02 01:56:45PM

I would ask that folks be precise about which Outlook they are talking about; Outlook for Exchange [OS 9 only]; Outlook Express for Mac; Outlook for PC?

Thanks.



[ Reply to This | # ]
Which Outlook?
Authored by: viega on Sep 12, '02 02:30:19PM

I was most concerned about interoperating with Windows users. However, I am told the Mac outlooks share the same problem.



[ Reply to This | # ]
Still better...theoretically then :)
Authored by: alex_kac on Sep 12, '02 09:15:46PM

OK, I admit - I haven't done much of folder actions on OS X, but I've heard good things from others who have.

Now, I wasn't aware that you have to reset the folder action each time you login. If so, then Folder actions are seriously broken in OS X.

In any case, for the normal Mac user, I still think that Folder actions are better - if the underlying tech works. Even if the AppleScript calls the shell script - its better if you can do a seamless install for them.

That's all - I prefer the shell scripts myself, but I think it will intimidate most Mac users who need to deal with this.



[ Reply to This | # ]
A script to easily add Outlook invites to iCal
Authored by: Nikolay Komarov on Apr 13, '06 04:34:09AM
Hi!
I tried your script and discovered that it doesn't work for me. I have Mac OS X 10.4.4 and my env differs from what your scripts expects: first of all, I don't have any ~/bin, so I had to leave this program just in ~; second, the script did nothing until I replaced:
item=mime-attachment
with:
item=mime-attachment.ics
I think it's my personal setting, that the extensions aren't hidden. I've posted it just in case someone else will find it useful.

In the end I'd like to thank you and to ask for a little continuation of your respectable effort. There is a little problem left that doesn't let me be happy. After my MS Windows-ed colleague receives my invitation and successfully (as he thinks) replies to it, I receive his confirmaton to my Mac OS X Mail and get a notification in iCal about this fact, but after I press OK to process this confirmation iCal does nothing. Seems like somewhere inside the confirmation processing routine there is a couple of code lines that expect some data portion that is actually ignored by Outlook.
We need to fix it!! :-)
I'm not that good in sed but I could provide you with sample invitation confirm files so that we could make a great script together. What do you think?

[ Reply to This | # ]