macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Improving the Outlook for Entourage
Pages: 1, 2

The Outlook database is a PST file on Windows. It contains all the messages, notes, tasks, and calendar events for a particular user. I tried moving that file to Mac OS X to see if Entourage could read it, which it can't.



Paul said that he "discovered that an Outlook programming team was able to make Windows PST files 100 percent portable to and from Outlook 2001 Mac," something he calls "an astounding achievement." So perhaps there is hope that Entourage will one day read PST files directly. Until then, you will have no choice but to export your personal information as tab-delimited or comma-separated (CSV) text files.

"CSV files are better to work with, once you figure you a way to deal with all the quotes they use for every field since they can incorporate internal carriage returns, tabs and commas. So that is what I use with my Outlook converters even though I use tab-delimited text files for importing and exporting to and from Entourage. The converters convert CSV to tabbed text, Windows encoding to Mac, and readjust all the Outlook fields to Entourage ones.

There are some 87 contact fields in Outlook 2000, 92 in Outlook XP, 78 in Outlook 97, 29 in Outlook Express Windows, and 60 or so in Entourage, only 40 or so of which are actually equivalent. (Incredibly, Outlook allows only 3 email addresses per contact, whereas Entourage permits 13). The fields are all called something else, and they're all in a different order. The scripts take care of all that, often with user options for custom field-mapping and the ability to save your choices so you never have to go through this again.

The scripts add any unmapped fields containing information to the Notes, properly labeled, on a per-item basis, without cluttering them up with empty fields. Similarly, they will set reminders for calendar events and tasks and transfer Outlook's more exotic fields that have no Entourage equivalent to the event and task Notes, so you don't lose any data. There are special options for mapping some calendar and task fields in non-English versions of Outlook since the fields are in an unknown alphabetical order in other languages. The scripts handle all that too.

The same CSV files that can be imported into Outlook can also be imported into the Yahoo calendar and Address Book and the Hotmail/MSN Calendar, so you can now synch an online calendar with your Entourage calendar if you wish. Other converters help with other PIMs such as Palm Desktop and with Excel.

Entourage itself is much less good about exporting and importing from text files than Outlook is: only contacts can be handled by a built-in feature, and this method loses categories, carriage returns and a few other things in the process. This is where my Entourage Export and Import scripts come in. The same scripts that import and export items to and from other identities in Entourage X and 2001 also do the same for the files converted by the Outlook Converter scripts. They can also provide the missing bits for contacts."

Paul said that his scripts were made possible because "Entourage X has such a superb implementation of AppleScript, with a "model" object model." He said that scripting in Entourage 2001 was not completely finished and his earlier scripts required "contorted workarounds" to handle recurring events, reminders, and due dates.

"It was a real pleasure to see the great improvements in Entourage X. Entourage's AppleScript implementation was done by Dan Crevier, who has now taken over from Jud as Entourage's Development Manager. There are not many applications whose Big Boss is the AppleScript programmer, and it shows! I couldn't have done anything like these scripts in many applications. (It would be totally impossible in Palm Desktop, for example. I do have converter scripts in the package that work with PD's Import/Export features, however.)"

I asked Paul to share an example of what he liked about Entourage's implementation of AppleScript.

"There are some applications whose AppleScripting consists mostly of a long list of unique proprietary commands with unique names. You can never memorize more than a few of them and have to be continually looking them up. There's no particular logic to it. Excel is an example. Others may look all right, but don't work properly (that's worse): Word is an offending example.

Entourage's AppleScript dictionary consists mostly of "classes" -- objects, nouns -- with a few "events" -- verbs, mostly from the Standard Suite. The classes have elements, which in turn are other classes, all being items you access and are familiar with in the User Interface (on the screen). It's structured like a well-behaved tree with branches. Even some properties (such as 'category') are common to more than one class. Entourage also has a thorough implementation of 'whose' filters, which are much nicer to use than repeat loops everywhere.

For example, to get just future events of the Work category:

 set currentDate to current date
tell application "Microsoft Entourage"
    set selectedEvents to every event where its category contains 
    {category "Work"} and its start time is greater than currentDate
end tell

That's a lot nicer than:

set selectedEvents to {}
set currentDate to current date
tell application "Microsoft Entourage"
	
    set allEvents to (every event)
    repeat with i from 1 to (count allEvents)
		
        set theEvent to item i of allEvents
        if category of theEvent contains {category "Work"} and 
        start time of theEvent is greater than currentDate then
			
            set end of selectedEvents to theEvent
        end if
    end repeat
end tell

(But don't try the first example in Entourage 2001 because 'where its' had not been implemented there for 'category'.) You might have only 20 future events in your calendar and only 10 of them Work-related, but the second version still has to slog through all 2000 past events in your identity. There are still a few things you can do on the screen, especially in the Calendar, that you can't yet do in AppleScript (such as selecting an event). But, by and large, you can not only do almost everything else by AppleScript, but even many things that are impossible to do in the UI. These Export-Import scripts do not, of course, do fancy tricks but just extract and recreate it. The thorough-going nature of the AppleScript implementation allows replicas to be recreated in the importing identity: if important properties weren't scriptable, you couldn't do it."

When I contacted Paul originally, I thought this AppleScript hotshot was a student. It turns out he is a professor, teaching piano at the University of California, Santa Barbara.

"I've only had a computer for about five years (the university finally insisted I have one, although I refused one when I first arrived). I migrated to Outlook Express Mac about three years ago (fed up with Eudora Lite) and thence to Entourage when I was invited to be a beta tester. At about the same time I moved to OE, I also discovered AppleScript, which I really took to. In my teens I had really liked math and logic, but I had given all that up to pursue music. AppleScript seemed like an intricate game to me-- it's sort of what doing complex crossword puzzles are for other people.

Most of my scripts (almost 200 now) were dreamed up as solutions to the puzzles posed by people on mailing lists or newsgroups--"Why can't I do something or other in Entourage?" It's the follow-through that takes time--I like to make my scripts very professional, with lots of options."

However, he says that he uses very few of his own scripts on a regular basis. (So much for Paul Berkowitz scratching his own itch, a la open source development.)

"As far as Export-Import Entourage goes, I have very little use for it myself. Now and again I do want to transfer data from my desktop to my iBook (both running Entourage X). I don't even have a Windows PC, but I got Virtual PC some time ago when I wanted to figure out how to port just contacts from Outlook. (Microsoft sent me a free copy of Office Windows so I could play with it.) Ever since then, I'd had in the back of my mind the project to transfer the calendar--I knew it could be done.

When Entourage X was released without Palm synching last October, I came up with some workaround scripts for synching Entourage X to Entourage 2001. That's when I got really ambitious and decided I'd write scripts to transfer everything. From there it was a short step (so I thought) to writing converters specifically for Outlook, since there seemed to be masses and masses of new Mac OS X and Office X users looking for a way to migrate from Outlook Windows, and other converters for Excel. The Excel method proved too complicated for export/import from other applications, so I came up with a few more converters. What I thought would be a major effort of perhaps two months (rather than my usual scripts, which might take a few days to polish) expanded into this monster project of 50 scripts for each of Entourage X and 2001, and has taken no less than eight months to complete. There's somewhere between 60,000 and 70,000 lines of code in all."

Dan Crevier says that he is "very impressed" by Paul's work. Paul has been a beta tester for Entourage. "We've used his feedback to help prioritize our scripting work to enable as many scenarios as possible," said Dan. "I feel that our effort here has really paid off. Instead of implementing a bunch of custom code to import from every possible application out there, we've made it possible for people to write scripts to import from any current or future clients. AppleScript opens up a world of possibilities."

I'm looking forward to trying Paul's scripts and see if I can have a cleaner import of Outlook data into Entourage. I also think that the ability to export personal data from Entourage will be useful as well. Another route I am exploring is syncing data up with my iPAQ, Pocket PC. I'll write about that process in a future article. I don't want to give up my iPAQ when moving to OS X.

So, PC users moving to Mac OS X have Paul Berkowitz to thank for helping them port their personal data to a new platform. Apple and Microsoft should also be thankful, as well as a little embarrassed that they are relying on an individual developer to make up for their own shortcomings. Nonetheless, Paul's work also demonstrates the power of AppleScript.

Dale Dougherty is the editor and publisher of MAKE, and general manager of the Maker Media division of O'Reilly Media, Inc.


Return to the Mac DevCenter.