Delete iMap Mail Accounts Offline Cache


If you’re experiencing a slower than usual Mail application, or it’s refusing to get or send new mail, follow these steps for a quick and easy fix by creating a simple AppleScript application.
Open up AppleScript Editor and copy and paste the following code then click the compile button and save the code as an application.
This Script will look through all the IMAP accounts that you have on your machine and will delete all of the offline cache!
—————————
display dialog “Delete Mail’s offline caches?” buttons {“Cancel”, “Delete”} default button 2
copy the result as list to {buttonpressed}
if the buttonpressed is “Delete” then
— For 10.7 use the line bellow
set thePath to (path to library folder from user domain as text) & “Mail:V2”
— for 10.6 Comment the line above and use the one bellow
— set thePath to (path to library folder from user domain as text) & “Mail”
tell application “Finder”
set theIMAPFolders to (every folder of folder thePath whose name begins with “IMAP”) as alias list
end tell
repeat with thisFolder in theIMAPFolders
set theCachePath to (POSIX path of thisFolder & “.OfflineCache”)
do shell script “rm -rf ” & theCachePath with administrator privileges
end repeat
end if
—————————
To use the script, first, quit Mail.app, then launch the the script’s.
The script will then give you a message to confirm if you sure you want to delete all offline cache files then you need to enter your administrator’s name and password.
Once finished the script deletes the ‘.OfflineCache’ folder from all of your IMAP-style email accounts.
Click here to download the file fully built and ready