Purge Outlook Emails

Ever have to convert from an email system that encourages keeping everything to one with limitations? Well, here’s a way to encourage Inbox Zero. I looked at a few different scripts to start from, but this one was the most helpful. Note that this only works with “old” Outlook, new Outlook has no AppleScript support at this time.

tell application “Microsoft Outlook”

set accountName to name of default account

set myInbox to folder “Inbox” of exchange account accountName

set mySentItems to folder “Sent Items” of exchange account accountName

my DeleteReadMessages(myInbox, 14)

my DeleteReadMessages(mySentItems, 14)

end tell

on DeleteReadMessages(targetFolder, cutoff)

tell application “Microsoft Outlook”

set cutoffTime to cutoff * days

with timeout of 600 seconds

set theMessages to (messages of targetFolder whose is read is true)

end timeout

set today to (current date)

set countEmailsDeleted to 0

set mailboxName to name of targetFolder

repeat with theMessage in theMessages


set messageTime to time received of theMessage

set messageAge to today – messageTime

if messageAge > cutoffTime and (is read) of theMessage is true then

set countEmailsDeleted to countEmailsDeleted + 1

permanently delete theMessage

end if

on error errorMsg

log “Error: ” & errorMsg

end try

end repeat

display notification “Outlook cleanup ran at ” & today & ” – ” & mailboxName & “:” & countEmailsDeleted & ” messages were deleted.” with title “Email Cleanup” sound name “Sosumi”

end tell

end DeleteReadMessages


Other AppleScripts:
Go offline and online automatically
Clean up Apple reminders
Notification silencer (maybe out of date, the OS does this now? But I’ve still updated it anyway)
Deleting all the email does speed Outlook up… so maybe deleting old meetings from the calendar would help it too? I did write that script, but I can’t recommend it. First, you can’t delete old meetings, only cancel them: so it sends cancellation notices by the thousands. Second, taking this hit doesn’t actually make Outlook client go any faster. Outlook Web Access seems to be the best option for calendar use.

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this: