Applescripting Outlook 2011 to import from Entourage 04/08/.rge

acdesigntech
Contributor II

Anybody used Office 2011's SP1 addition of import identity and import rge to automate importing Entourage identities/archives?

I can't seem to find much in the way of syntax for those commands. I did find JAMFs solution for GUI scripting, but I would rather use the built-in scriptability of the app.

Any ideas would be GREAT!

1 ACCEPTED SOLUTION

talkingmoose
Moderator
Moderator

I've got a new version of the Exchange setup script for Outlook that supports importing from Entourage 2008 or 2004. For now, I'm placing it on GitHub for download until I can get it better tested and documented. You'll find it here:

https://github.com/talkingmoose/Outlook-Exchange-Setup/tree/4.5

The "README" includes a handful of notes about what's changed. The actual script you'll want to download is "OutlookExchangeSetup4.5.scpt".

How it works

The old instructions for deploying the script remain the same. Nothing has changed with that.

When the script runs it will check for the existence of:
- ~/Documents/Microsoft User Data/Office 2008 Identities/
- ~/Documents/Microsoft User Data/Office 2004 Identities/

If it doesn't find any old databases then it proceeds as before with configuring a new Exchange account.

If it finds any Entourage identities it will prompt the user to "Upgrade" or create a "New" email database. If he selects "New" then it proceeds as before with configuring a new Exchange account.

If he selects "Upgrade" the script it will create a list of the existing Entourage database identities (ignoring backup folders created when repairing the database) and prompt him to select one. I've included the modifications dates to indicate the most recent version vs. older versions. (I opted not to enable importing multiple identities because doing so could possibly create multiple accounts with the same settings.)

When the user chooses an Entourage identity the script begins the import process. Because AppleScript doesn't support things like progress bars or dynamic dialog boxes I have to use a rudimentary "dialog" window to show progress. I update the dialog every 20 seconds but that's a new configurable option in the properties list at the top of the script. Setting this to a lower number (more frequent) will have a noticeable impact on import time.

During the import the script is looking at the CPU usage by the "Microsoft Database Daemon". This is the application actually doing the import. Generally, it will use less than 5% of CPU at any given time. So long as the script reads that the Database Daemon is consuming more than 5% CPU for an extended period of time then it continues to update its progress.

In my limited testing on my 2.4 GHz MacBook Pro with 8 GB RAM and a 5400 RPM drive I am importing a 2.5 GB database in about 18 minutes. Keep in mind that the import process does not import Exchange account or IMAP account messages/events/contacts/tasks/notes. Microsoft expects those to download from the server. The script should import:

  • Any messages/events/contacts/tasks/notes copied from an Exchange or IMAP account to folders under "On My Computer"
  • Accounts
  • Delegate accounts
  • Autocorrect rules (I think)
  • Categories
  • Rules
  • Schedules
  • Signatures

I'd appreciate feedback from anyone who tests. :-)

@Don You're allowed a year to give feedback since you had to wait that long.

View solution in original post

18 REPLIES 18

gachowski
Valued Contributor II

Andrew,

I know this isn't what you asked for, but it is a pretty good place to start!!

http://www.officeformachelp.com/outlook/exchange/setup-script/

I think there there is more info here about script entourage but the search is broken for me.

http://blog.talkingmoose.net

C

acdesigntech
Contributor II

Im currently using the setup script in the link above, but it doesnt address importing the local entourage folders or .rge archives

talkingmoose
Moderator
Moderator

A year ago I started to incorporate an import option into the setup script but I was never happy with the results. The issue was with the length of time some databases may need for importing and the patience of users. My 2 GB test database took about 20-25 minutes on my laptop.

I worked in a notification system that updated progress every 20 seconds so that the user could see the process was still running. It was a little kludgy but effective. Later I thought about including Growl support but didn't move to that.

For my users here I was content to provide written instructions for importing if they wanted to do that. Many chose not to do that because they didn't archive mail locally.

If you're interested in what I have for importing then let me know and I'll put it all together in the script.

acdesigntech
Contributor II

Hey William,

Yes I'd definitely be interested. Our users have a super low quota for live exchange mail (<50 MB) so archive locally often.

I was also planning on incorporating an entourage database repair prior to the migration, so that might help a bit. Speed isn't really a concern here since our mgmt team has forced the issue of "do absolutely everything for the user."

acdesigntech
Contributor II

@talkingmoose... script?

talkingmoose
Moderator
Moderator

Sorry for not responding. I'll need to work on this over the weekend. They're in a couple of pieces but they're done for the most part.

acdesigntech
Contributor II

Heh, sorry to be a pest. Thanks for this!

I know how busy it can get, we're currently migrating over 2500 workstations from XP to 7, and it's not going... smoothly. Take your time!

Also, if you wanted to just send the pieces over, I can put them together and see if I can make any tweaks or anything and send the finished product back?

talkingmoose
Moderator
Moderator

I've got a new version of the Exchange setup script for Outlook that supports importing from Entourage 2008 or 2004. For now, I'm placing it on GitHub for download until I can get it better tested and documented. You'll find it here:

https://github.com/talkingmoose/Outlook-Exchange-Setup/tree/4.5

The "README" includes a handful of notes about what's changed. The actual script you'll want to download is "OutlookExchangeSetup4.5.scpt".

How it works

The old instructions for deploying the script remain the same. Nothing has changed with that.

When the script runs it will check for the existence of:
- ~/Documents/Microsoft User Data/Office 2008 Identities/
- ~/Documents/Microsoft User Data/Office 2004 Identities/

If it doesn't find any old databases then it proceeds as before with configuring a new Exchange account.

If it finds any Entourage identities it will prompt the user to "Upgrade" or create a "New" email database. If he selects "New" then it proceeds as before with configuring a new Exchange account.

If he selects "Upgrade" the script it will create a list of the existing Entourage database identities (ignoring backup folders created when repairing the database) and prompt him to select one. I've included the modifications dates to indicate the most recent version vs. older versions. (I opted not to enable importing multiple identities because doing so could possibly create multiple accounts with the same settings.)

When the user chooses an Entourage identity the script begins the import process. Because AppleScript doesn't support things like progress bars or dynamic dialog boxes I have to use a rudimentary "dialog" window to show progress. I update the dialog every 20 seconds but that's a new configurable option in the properties list at the top of the script. Setting this to a lower number (more frequent) will have a noticeable impact on import time.

During the import the script is looking at the CPU usage by the "Microsoft Database Daemon". This is the application actually doing the import. Generally, it will use less than 5% of CPU at any given time. So long as the script reads that the Database Daemon is consuming more than 5% CPU for an extended period of time then it continues to update its progress.

In my limited testing on my 2.4 GHz MacBook Pro with 8 GB RAM and a 5400 RPM drive I am importing a 2.5 GB database in about 18 minutes. Keep in mind that the import process does not import Exchange account or IMAP account messages/events/contacts/tasks/notes. Microsoft expects those to download from the server. The script should import:

  • Any messages/events/contacts/tasks/notes copied from an Exchange or IMAP account to folders under "On My Computer"
  • Accounts
  • Delegate accounts
  • Autocorrect rules (I think)
  • Categories
  • Rules
  • Schedules
  • Signatures

I'd appreciate feedback from anyone who tests. :-)

@Don You're allowed a year to give feedback since you had to wait that long.

acdesigntech
Contributor II

Wow! Thanks for this. I have a lot of work to do tomorrow! Or not.. looks like you took care of just about everything!

Thanks for this, a million times over!

acdesigntech
Contributor II

Really nice script. I ended up having to tweak it for the following for our environment:

  1. used dscl . -read /Users/username to get the email address. For some reason it wasn't consisten when trying to access AD.
  2. took out the menu for what identity to delete. Our assumption here is that people will only ever have a single identity (non-backup) to migrate. Of course there are exceptions, but 99% will e like this, and mgmt does not want any user intervention if we can help it.
  3. While pretty darn cool, I did end up taking out the time feedback loop. We're planning to just use jamfhelper to create a splash screen to lock the users out while migrating - just easier that way. We have fairly intrepid Mac users that like to mess with stuff :)

That said, the script works like a charm, and I'm REALLY excited about the feedback possibilities with the display alert loop you created. However, it didn't seem to be reading my MS Database Daemon process correctly. It would be finished with the import, the process would drop to 0% CPU, and the loop would keep going. Granted I did have a fairly small test database (<35 MB). Is it possible that if the process never hits MORE than 5% CPU, it can create an infinite loop?

talkingmoose
Moderator
Moderator

I greatly appreciate the feedback on this and I like what you've done to make it fit your environment—especially, incorporating the jamfhelper tool.

Regarding your observations about reading the database daemon, you're correct that it will finish and the script will continue to loop a bit longer. The reason for this is the database daemon process may at one or several points drop to less than 5% because another process is consuming the CPU cycles.

My solution was to verify the process was indeed done by counting the number of times in a row it was less than 5%. The default number is 6 (the variable is called CPUCounter). That number can probably be adjusted lower. It's what I was using when I had the notifications set at every 10 seconds instead of 20. Between these three adjustable settings:

  1. refreshRate = 20 seconds
  2. CPUUsage = 5%
  3. CPUCounter = 6 times

there's probably a happy optimized medium.

I think in a later version I'd like to incorporate support for Growl, OS X 10.8 Notifications and probably the jamfhelper too. The end user really needs a status notification or a hard lock on the machine while the import progresses.

Please keep me posted of your results. I'm always curious to hear reports.

acdesigntech
Contributor II

So I've been able to modify the script to auto migrate the Main Identity folder, if there is one, and set up the outlook account. I'm trying to do this with a locked screen using jamfHelper, but running into a few snags:
1. I have written the script to run through Casper Remote as mainly a bash script, using the

osascript<<EndMigration
...
EndMigration

method of implementing the applescript that does all the migration and setup. I keep getting the following error message: "Script Result: 17357:17433: execution error: No user interaction allowed. (-1713)" Note: I also get this message if I don't try to lock the screen with jamfHelper. And yes, someone is logged in to the console.

  1. I also have tried invoking jamfHelper from the applescript itself with a
    do shell script "/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading 'Your Email Account is being Migrated' -description 'We are now upgrading your email account from Entourage to Outlook 2011. Your upgrade may take between 5 minutes and 2 hours depending on how much email you have. If you still see this window after 2 hours, please contact the helpdesk at X4949. Please do not turn off this computer. This message will go away when the upgrade is complete.' -icon /Applications/Microsoft Office 2011/Microsoft Outlook.app/Contents/Resources/Outlook.icns &"

and capturing the process ID with

set MigrationPID to (do shell script "ps -ax | grep -v grep | grep jamfHelper | awk '{print $1}'")

But the script just hangs and waits for the jamfHelper process to be done. Is there another way to have the fullscreen from jamfHelper and have other things running in the background? How would one accomplish this? Then how do I know at the end to kill jamfHelper?

talkingmoose
Moderator
Moderator

I haven't myself tried the jamfhelper in full screen. Doesn't killing it require first using the -startlaunchd switch? I think this is done to allow the script to continue running without waiting for something to be returned from the jamfhelper window.

acdesigntech
Contributor II

No, I can issue a "killall jamfHelper" to kill it, what do you mean by -startlaunchd? Where would I use that switch?

talkingmoose
Moderator
Moderator

Run /path/to/jamfhelper -help and you'll see it listed as an option.

acdesigntech
Contributor II

So, for anyone interested enough, with jamf's help I got jamfHelper -windowType fs working with talkingmooses script, it was a simple matter of adding these lines in the right order, and the reason jamfHelper was hanging was because I wasn't dumping it's non-existant output somewhere, so the script ended up waiting for nothing. Not sure if that's a quirk of 8.1 or not, but since I'm still on Casper 8.1 (going to 8.6 shortly), well, here ya go:

set jamfHelperPID to do shell script "ps -ax | grep -v grep | grep jamfHelper | awk '{print $1}'"
if jamfHelperPID is not equal to "" then
    do shell script "killall jamfHelper"
end if
do shell script "/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading 'Your Email Account is being Migrated' -description 'We are now upgrading your email account from Entourage to Outlook 2011. Your upgrade may take between 5 minutes and 2 hours depending on how much email you have. If you still see this window after 2 hours, please contact the helpdesk at X4949. Please do not turn off this computer. This message will go away when the upgrade is complete.' -icon /Applications/Microsoft\ Office\ 2011/Microsoft\ Outlook.app/Contents/Resources/Outlook.icns > /dev/null 2>&1 &"

You have to do a final "killall jamfHelper" once the loop exits to get rid of the last jamfHelper window, but this has to be in it's own tell block, I've noticed. Otherwise you won't get the jamfHelper window to come up at all. It's probably something silly in my code, but it does work... so

tell application "System Events"
     if jamfHelperPID is not equal to "" then
          do shell script "killall jamfHelper System\ Events"
     end if
end tell

That bit about killall System Events was from some advice I got from JAMF about having to kill system events after using JH in full screen mode because of some potential wackiness with mouse clicks and key strokes unless Sys Events is killed too.

The best part? The FS created by jamfHelper does not "flicker" like the display alert. I don't know, I guess I'm picky :P But you trade off not getting an update every X seconds.

I'm running this in the user context too, so unfortunately the /L/A S/JAMF/bin/ directory does need to be made readable by everyone in order to work in the user context.

So the last bit of talkingmoose's applescript looks like this for me:

tell application "System Events"
        set PID to unix id of process "Microsoft Database Daemon"
        set CPUUsage to 10
        set CPUCounter to 0

        set startTime to (current date)
        repeat while CPUUsage as integer ? 5 or CPUCounter ? 3 -- The Microsoft Database Daemon must be utilizing less than 5% of CPU for one minute before the import is considered complete

            -- Adding a try statement here because sometimes the result of this command is simply garbage.

            set elapsedTime to (current date) - startTime

            -- format the time as "00:00:00"

            set hrs to elapsedTime div hours
            if hrs < 10 then
                set hrs to "0" & hrs as string
            end if
            set mins to elapsedTime div minutes
            if mins < 10 then
                set mins to "0" & mins as string
            end if
            set secs to elapsedTime mod minutes
            if secs < 10 then
                set secs to "0" & secs as string
            end if

            set formattedTime to hrs & ":" & mins & ":" & secs as string

            try
                set jamfHelperPID to do shell script "ps -ax | grep -v grep | grep jamfHelper | awk '{print $1}'"
                if jamfHelperPID is not equal to "" then
                    do shell script "killall jamfHelper"
                end if
                do shell script "/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading 'Your Email Account is being Migrated' -description 'We are now upgrading your email account from Entourage to Outlook 2011. Your upgrade may take between 5 minutes and 2 hours depending on how much email you have. If you still see this window after 2 hours, please contact the helpdesk at X4949. Please do not turn off this computer. This message will go away when the upgrade is complete.' -icon /Applications/Microsoft\ Office\ 2011/Microsoft\ Outlook.app/Contents/Resources/Outlook.icns > /dev/null 2>&1 &"
            on error
                activate
                display dialog "Process too busy to read at this moment. Will try again in " & refreshRate & " seconds." giving up after refreshRate buttons {"OK"} with title "Upgrading Entourage Database…" with icon alias ((path to applications folder as string) & "Microsoft Office 2011:Microsoft Outlook.app:Contents:Resources:Outlook.icns")
            end try

            set CPUUsage to do shell script "ps aux | grep " & PID & " | grep -v grep | awk '{print $3}'"

            -- The "Microsoft Database Daemon" may be inactive for several seconds during the import process but the import may not necessarily be done. This section ensures that the daemon has been at less than 5% CPU usage 3 times in a row before considering the import is complete.

            if CPUUsage as integer ? 5 then
                set CPUCounter to CPUCounter + 1
            else
                set CPUCounter to 0
            end if
        end repeat
    end tell
end if

-- End account setup

-- Script clean

-- We're done. Set the schedules back to normal and set Outlook to work online tell application "Microsoft Outlook" set enabled of schedule "Send & Receive All" to scheduled delete exchange account 2 -- upgrading an identity causes a second account to be created and we certainly don't want that tell application "System Events" if jamfHelperPID is not equal to "" then do shell script "killall jamfHelper System\ Events" end if --activate --display dialog "Outlook is ready to use." buttons {"OK"} default button {"OK"} with icon alias ((path to applications folder as string) & "Microsoft Office 2011:Microsoft Outlook.app:Contents:Resources:Outlook.icns") with title "Setup Complete" end tell set working offline to false delete schedule "Exchange Setup" end tell

karthikeyan_mac
Valued Contributor

Hi,

I am working on importing the Outlook 2011 Identity to Outlook 15 through Apple Script. I was able to import the olm file using "import olm" in applescript but "import identity" is not recognized by Apple Script. Did outlook still has "import identity" keyword for Applescript?

Or do we have any other way to import Outlook 2011 Identity to Outlook 15.8 ?

Thanks & Regards,
Karthikeyan M

talkingmoose
Moderator
Moderator

Just compared the AppleScript dictionaries for Outlook 14 and 15. The Import Identity command is gone. Outlook 15 currently has this feature in the GUI only.

If you've installed Outlook 15 on a Mac where Outlook 2011 was already installed and the user had an identity, the user should be prompted to import. It's not automatic but it's an option.

Also, Outlook 14 and 15 don't actually import messages stored in IMAP and Exchange accounts. They'll import your account settings, preferences, local calendars and contacts but still re-download all your mail data from the server. Might be useful to know if you didn't already.