Auto Archive Script for Outlook Mac 2011

Posted: September 3, 2012 in AppleScript
Tags: , ,

Out the box Microsoft Outlook for Mac 2011 has no equivalent tool to the auto archive functionality found in Outlook for Windows.

UPDATE:

I have now released a new tool for archiving in Outlook Mac 2011 which is a native Mac Application. It is significantly more stable, featured and faster than the AppleScript. It also supports archiving mail to the cloud (such as a GMail account) which keeps your archive safely backed up and accessible/searchable anywhere in the world. To download and see the features and screenshots of the new Outlook Mac Archive Tool go here
Installer DMG

It’s a significant improvement over the free applescript when comparing the features. If you’ve enjoyed the free AppleScript, please consider upgrading to Outlook Archive Tool even just as a donation for the hard work:

Feature Comparison

Feature Table

Background

If you aren’t in the know: Archiving for Outlook is a process of automatically copying your full email folder structure and/or calendar events from the exchange server to a local folder structure on your computer. It’s used in scenarios like:

– Your company operates a data limit or ‘delete mail after x days’ policy which means you must move mail out of the exchange account to not cause disruption to your flow of mail (or to not suffer data loss of important mails in your past history)

– You want to keep your exchange account lean for performance reasons, but still be able to search gigs of mail going back many years

– You have a number of attachments in calendar events from years back that accumulate over time to lower the available data quota for email

– You aren’t happy with more manual methods of dragging mail down to your local storage when you happen to remember…etc

The search for a tool:

First stop was to Google for an AppleScript that would do the job. Though I found an simple implementation for Mac Mail there was nothing I could find for Outlook Mac 2011 that matched the features of the Windows version.

Commercial tools were poor at the time and after messing with Outlook Rules and finding them too weak I was inspired to create this script.

UPDATE:

My new commercial tool for archiving in Outlook Mac 2011 is now available. It’s possibly the most featured on the market right now and the only tool to support archiving to the Cloud. You can read more here

Features of the script:

– A script which by default will archive mail from your primary exchange account using the following default archive settings:

  • Archive mail older than 80 days from all folders (except folders like ‘Subscribed Public Folders’, ‘Junk Mail’, ‘Deleted Items’, etc)
  • All archived mail folders will be placed under the folder of ‘On My Computer’ called ‘Archive Mail’
  • All non-recurring calendar items older then 2 years will be archived to a calendar of ‘On My Computer’ called ‘Archive Calendar’

– The script has a number of parameters which you can change if you are not happy with the default settings.

– Calendar and mail archiving can be configured separately, depending on your needs.

– Fire and forget: … using the ‘Tools’ menu in Outlook and ‘Run Schedule’ you can run the script on a regular basis.  For example, configuring a schedule in Outlook as depicted below will run the archive script daily.

– NOTE: Outlook by default hides your ‘On My Computer’ folder go to Outlook–>Preferences–>General and use below settings

DOWNLOADS

Script [Ver 2.20]: http://bit.ly/11EIzUo

Change log 2012/12/08

– If you create a category in Outlook called “Do No Archive” there is a setting in the script that will now ignore any mails or calendar items assigned to this category even if they are candidates for archiving

– You can optionally enable a setting to not archive items flagged as Todo but are not yet marked complete even if they are candidates for archiving

– You can now archive recurring calendar events (but be warned that will remove the entire series even in to present day so use with caution)

– AppleScripts default timeout period that it waits for applications like Outlook to finish processing a task is quite short. The script now overrides this to 2 minutes by default but it can be made longer if you still experience timeouts (especially when you first run the script on a large mailbox and it has to process a long back log of archive items).

Script [Ver 2.13]: http://bit.ly/Srh2md

Change log 2012/11/27

– Added in a simulation mode setting which allows you to review the empty archive folder structure created on ‘On My Computer’ without moving all the mail and calendar items (can be run repeatedly without issue). If run in the AppleScript Editor the candidate mail/events that will be moved once simulation is turned off are logged to the events window. This allows you to test out various parameters to the script to see the effect before archiving any items.

– Added in a new setting which allows you to archive sub-folders of excluded folders. Useful if you want exclude your inbox but still archive sub-folders of the inbox. By default this setting is not turned on and any excluded folder that is listed will also have it’s sub-folders ignored.

– Found that attempting to archive “sync errors” folders was causing the script to lockup. Updated the default exclusion folder to ignore this folder

– Timeouts can also occur on slower CPU machines when Outlook can’t move the mail quick enough for the speed of the script. Made this a parameter and increased it to 200ms delay between message moves. This mostly affects the initial archive processing when you have large back log of mail which can take a long time and is most prone to timeouts. When run daily this small speed delay will make very little difference. If you aren’t suffering from timeouts then you can change this parameter to .1 or zero seconds. [UPDATE:  In version 2.2 (to be released shortly) I have added an overall script timeout parameter too that, if increased, will stop the script from timing out when there are large volumes of mail to process (usually only on the first time you run the script on a large mailbox)

Script [Ver 2.12]: http://goo.gl/RtDPy

Change log 2012/11/05

– For most users the script works flawlessly but a small percentage of users have problems detecting the Archive Folder or the Archive Calendar especially if they customise the script parameters. I can’t replicate the problem but this release is an attempt to fix the routine that creates these folder/calendars to see of it makes a difference

Script [Ver 2.11]: http://goo.gl/lYgZK

Change log 2012/10/13

– When using the script for the first time on a large mailbox the script could lock up Outlook due to bug in Outlooks message move command. Outlook can’t handle the speed at which the script is sending move requests. By introducing a slight delay between processing of messages the script can now manage very large mailboxes (though it will take a little longer on first run)

Script [Ver 2.10]: http://goo.gl/lEXh4

Change log 2012/10/06:

– Script now looks for the primary exchange account automatically which means if you are happy with the default archive settings (see blog post above) then it will just run out the box with no need to edit the script file and fill in exchange account name and other parameters (proving difficult for less technical users)

– Wrote a post on configuring the script for those that want to modify the default settings or other more advanced tasks

Script [Ver 2.0]: http://goo.gl/syzIV

Change log 2012/09/20:

– Added in the feature to optionally archive calendar events

– Can independently control the mail and calendar archive settings

Script [Ver 1.01]: http://goo.gl/7nKgv

Change log 2012/09/18:

– The archive folder specified will be created if not found under ‘On My Computer’

– Attempts to fix the problem that on some Mac/Outlook versions this script fails to find the archive folder when it is created manually

Script [Ver 1.00]: http://goo.gl/Xplpt 

– Initial release

Disclaimer: Free to use but 100% at your own risk (works for me)

Feedback/Bugs/Suggestions welcome

Advertisement
Comments
  1. David L says:

    Michael – I have been using your auto-archive-script-for-outlook-mac-2011 for five years – it has been great!! I am now wanting to transfer the “Archive Mail” destination folder to Outlook 2016 as MS no longer supports Outlook 2011. I have tried the Export options Outlook 2011, it picks up all the other folders that are on my Mac Outlook 2011 but not the “Archive Mail” folder. Do you know how I can transfer it to Outlook 2016? Thanks again for your great script and hopefully for your help with this problem. David

  2. Dirk says:

    I still use Outlook for MAC 2011 (14.7.1) and like to move to Outlook 2016 (15.32). How do I use the profile to move my archived items to OL 2016?

  3. SK says:

    Hi Michael

    Many thanks for creating the script, which addresses the key gap in Outlook for Mac.

    One question – I would like to archive the sent items to the Sent Items folder in “On My Computer”, so that if I group similar folders together, it is much easier to search for emails, regardless where it resides. How could I do that?

    Appreciate your help.

    sk

    • Hi SK

      Thanks for the feedback 🙂 The script is specifically built to have a ‘root folder’ as your Sent Items or Inbox under ‘On My Computer’ are where mail are stored when you use POP accounts. For this reason it was wise not to mix them. It is possible but it would require a coding modification to the script to use ‘On My Computer’ as the root folder.

      • SK says:

        Hi Michael

        How easy is it to get it modified? I do not use POP accounts as my Outlook is strictly for Exchange use. Thanks.

        sk

        • It will need some investigation, it’s not trivial but also not hard if you have some basic scripting skills. We have quite a roadmap on our new tool however so unlikely we could make this change anytime soon. Are you able to program?

          • SK says:

            Only done simple scripts. Will take a closer look, probably do not need most of the features of the script. Thanks.

  4. Mark Ward says:

    Just bought it Michael, it’s brilliant, thank you!

  5. Abberz says:

    Hello

    I’ve used the archiving script to successfully archive off emails, which is great.

    I now need to reimport those archived emails into a NEW Outlook identity. How would I do this?

    Whereabouts on my hard drive are the archived emails stored?

    Thank you

    • Hi Abberz, it’s stored under Documents/Microsoft User Data/Office 2011 Identities. Glad you enjoy the script. There are many reasons to upgrade to my new tool which is considerably more featured. It also allows you to transfer mail between email accounts (from one Exchange account to another, backup mail in the cloud like a Gmail account etc) You can check it out and download a demo which will run in simulation mode (similar to the concept in the script)… https://blog.7thdomain.com/store/outlook-mac-auto-archive-tool/

  6. CB says:

    I installed the script yesterday and it seemingly worked well for a while, but eventually stopped. Now whenever I re-run the script I get this Apple Script Error:

    Microsoft Outlook got an error: every mail folder of item 1 of {mail folder id 104, mail folder id 108, mail folder id 149, mail folder id 114, mail folder id 706, mail folder id 105, mail folder id 109, mail folder id 139, mail folder id 136, mail folder id 122, mail folder id 724, mail folder id 117, mail folder id 145, mail folder id 123, mail folder id 284, mail folder id 107, mail folder id 141, mail folder id 126, mail folder id 694, mail folder id 695, mail folder id 285, mail folder id 133, mail folder id 134, mail folder id 351, mail folder id 111, mail folder id 568, mail folder id 113, mail folder id 373, mail folder id 404, mail folder id 115, mail folder id 116, mail folder id 147, mail folder id 681, mail folder id 364, mail folder id 689, mail folder id 372, mail folder id 267, mail folder id 722, mail folder id 375, mail folder id 673, mail folder id 652, mail folder id 680, mail folder id 645, mail folder id 714, mail folder id 352, mail folder id 119, mail folder id 120, mail folder id 654, mail folder id 651, mail folder id 438, mail folder id 685, mail folder id 148, mail folder id 124, mail folder id 723, mail folder id 684, mail folder id 656, mail folder id 125, mail folder id 657, mail folder id 102, mail folder id 128, mail folder id 697, mail folder id 687, mail folder id 143, mail folder id 661, mail folder id 660, mail folder id 376, mail folder id 466, mail folder id 465, mail folder id 288, mail folder id 432, mail folder id 293, mail folder id 142, mail folder id 433, mail folder id 374, mail folder id 381, mail folder id 379, mail folder id 713, mail folder id 415, mail folder id 674} doesn’t understand the “count” message.

    Any ideas?

  7. Looking forward to trying this. It looks great

  8. Hi there. This script is great thank so much for your work and time spent on it. Instead of, archive to ‘On computer’ I need it to archive into another exchange mailbox, is this possible?

  9. Bill McDonald says:

    Probably a weak question, put is there a way to automatically create and export an .olm to periodically save it as a precaution. Save to Time Capsule or WD Passport

    • It’s a very good question. There are ways to backup your Outlook database but it’s very manual and it doesn’t allow you to easily look for that mail from the past once it’s backed up on a disk somewhere. My solution for this problem is Cloud Archive which is a feature of my new tool I just developed called Outlook Mac Archive Tool. It in realtime archives constantly to a cloud email account such as a GMail account. This keeps you mail backed up and always searchable. If your laptop fails you still have your archive backed up. You can read more here https://blog.7thdomain.com/store/outlook-mac-auto-archive-tool/

  10. Hello, Do you offer any one-to-one help? I’m a journalist and writer and while I can understand your words on how to figure out archiving in Outlook for Mac, I cannot implement anything because I don’t get half of the meaning of the phrases, and am worried that I’ll do something that will prevent outlook from working. I have to archive, though, because I keep filling up my mailbox and it isn’t practical. Any suggestions you might have or individual help you might offer would be appreciated. Thank you.

    Susan Herrmann

  11. SusanCooksin says:

    hello,

    I am a writer not a techie, and I have difficulties with outlook on my Mac, including knowing how to create rules and how to archive. That is, I think I know how to do both, but neither work with my outlook for Mac. I cannot really understand deeply what to do. Do you have anything for “dummies” like me?

  12. Bob Bracalente says:

    Still having some issues with the script. Please take a look at this snippet from the Applescript event log:

    tell application “Microsoft Outlook”
    (*Earliest Date – Thursday, August 15, 2013 6:05:20 PM*)
    get name of mail folder id 106
    –> “Deleted Items”
    count every mail folder of mail folder id 106
    –> 0
    get every mail folder of mail folder id 176 whose name = “Deleted Items”
    –> {}
    (*Creating folder Deleted Items*)
    make new mail folder with properties {name:”Deleted Items”} at mail folder id 176
    –> mail folder id 194
    get every message of mail folder id 106
    –> {incoming message id 93686, ..[Edit]… incoming message id 122326}
    get time sent of incoming message id 93686
    –> date “Tuesday, October 15, 2013 8:34:23 AM”
    (*Folder archive complete*)

    So today, I noticed that my “Deleted Items” folder wasn’t getting cleaned up by the script. When I looked at the config file, I noticed that “Deleted Items” is excluded by default. So I took it out of the list, saved the script & ran it from the script editor. The output above is what I saw when it processed the Deleted Items folder. It appeared to check one message, determined it was within the retention period, and went onto the next folder. The only problem is, there are files in Deleted Items that date back to 2012. So any idea why it would bail after one message?

    • Hi Bob, sorry for late reply, yes I think that’s a bug in the script. I think it incorrectly handles mails that have no sent date (perhaps a draft email you deleted). This causes it to bail early and never process the rest of the mails. I’m re-writing this tool as a native application and deal with this correctly, when it’s relased you may want to try that to better handle this.

  13. James Adams says:

    This works great, but it seems to lock outlook while it runs. No errors, just does not let me do anything in Outlook. I have played with the message move time out al the way to 5 seconds from 0ms and no luck. It completes successfully and then I have full control again. Seems to be hardware independent. Had the issue on a year old air with 10.8 and have it on a brand new MBP with Mavericks.

    • Hi James, thanks for your comments, sorry for late reply, unfortunately the script is very slow. However, I’ve now written a native multi-threaded application which will be considerably faster (seconds vs minutes) running time. When it’s released you can try this.

  14. patrick says:

    hi michael, thanks for the script – it is exactly what i am looking for, but i am not sure how to get it to run. after copying the script to ‘outlook script menu items,’ it doesn’t appear in the script menu in outlook. what am i missing? many thanks!

    • HI Patrick, sorry for vert late reply. You don’t need to copy to the script menu area in Outlook. You can just double click on it to run it in the Applescript Editor or you can schedule it per my blog post. I’m writing a new application that will be a lot easier to use than this script. You could also try that when I release it

      • patrick says:

        thanks again for making all our lives easier michael! 🙂 i got it to work a while ago & am super happy with the script. happy new year!

  15. Clive says:

    Hi Michael

    Does your script work only with Enterprise? I use 2011 for a POP account and was wondering if it would work for this?

    Thanks
    Clive

    • HI Clive, thanks for your comments. My Outlook Archive script only supports exchange but I’m writing a new native application to replace it that will support POP, IMAP and Exchange. When it’s released I’ll let you know.

  16. twitter.com says:

    Hey! This is my 1st comment here so I just wanted to give a quick shout out and say I truly enjoy reading your blog posts.
    Can you recommend any other blogs/websites/forums that cover the same subjects?
    Thanks a lot!

    • Thanks for your comment (sorry for very late reply), I’m glad my script helped you. If you google around on applescript topics you will find a lot. There aren’t many tackling Outlook scripting from what I’ve seen though.

  17. Michael, I can’t thank you enough, your script is installed and work well (through quite slow!!!). As a real novice I managed to use it thanks to your excellent instructions.
    All the best and thanks again
    David

    • Hi David, I’m glad my script helped you. Apologies for late reply. I’ve written a new application to replace my script which will be very fast compared so I’ll let you know when its out.

  18. whoah this blog is wonderful i like studying your articles.
    Stay up the good work! You recognize, a
    lot of people are searching around for this information, you could
    aid them greatly.

  19. steve says:

    Hi, Great script. Just what i needed. Many thanks for your time developing this. One question…Is there a way i can archive to an external hard drive? If so how do I do it? I get mega big emails for work, but are working on a Mac Air with smallish SSD so would prefer not to clog up with old data, so ideally want to run the script twice a month archiving to my external drive. Any info would be appreciated, thanks in advance.

    • Hi Steve, sorry for very late reply. I’ve written a native application to replace my script that will solve this problem and allow you to sync your On my Computer archive to a Gmail account. This allows you then to delete your local hard disk copy and access your mail in a searchable manner in the cloud. I will be releasing it soon.

  20. Alex says:

    Thanks for this script.

    In step 4 of your “Configuring Outlook Mac 2011 auto archive script” you mention that if “set exchangeAccountDescription to” is left as “ it will automatically use the first exchange account by default (recommended).

    In my case I have an IMAP Account. In this case should I leave the script as “”, or should I change it to something like “” (or the name that I have in my account description)?

    Alex

    • HI Alex, apologies for very late reply. I’ve been distracted actually writing a new native Mac application which does the same as my script but will be considerably better and support IMAP. As you probably figured out my script only supports exchange.

      • Kathi Nelson says:

        Hi Michael – I’m a new Mac user and am frustrated that I can’t find a way to archive my emails in Apple Mail or Outlook for Mac while maintaining their folder structure. All I can seem to figure out is how to archive to one archive folder where all emails are mixed together making it very challenging to find what I’m looking for. After an unsuccessful visit to the Apple store I’ve spent a bunch of time looking online for a solution and wondered if your script does what I’m trying to do?

  21. Very good info. Lucky me I came across your website by
    chance (stumbleupon). I’ve book marked it for later!

  22. Carlo says:

    Hello, I have just found your script “Archive Script for Outlook Mac 2011” and I was wondering if you could kindly suggest me a way to export/archive only messages/folders within ’Archive Mail’ ‘On My Computer’, so that I can reduce the size of the database/identity
    As far as I know, from Outlook 2011, you can only export .olm archives which include the whole structure (server/local folders) or filtered by categories (to export only messages belonging to a category)
    If you have a complex structure (nested folders) I don’t think you can automatically assign a category for all messages once they’ve been moved to ’Archive Mail’
    Many thanks for your kind attention
    Carlo

    • HI Carlo, sorry for very late reply but I’ve been very focused on a new Outlook Archive project which may achieve your end goal of reducing space. I’m writing a tool to sync your On My Computer Archive to a cloud email account such as Google. This makes a backup of your mail and keeps it all searchable and accessible from anywhere. You can then optionally remove mail from your local machine

  23. Excellent post. I was checking constantly this weblog
    and I’m impressed! Extremely useful info particularly the closing section 🙂 I take care of such info a lot. I used to be looking for this particular information for a very long time. Thank you and good luck.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s