This is an older version of the script
In Eudora, and some other email clients, accounts can be set to automatically check for new mail on a per account custom interval. Apple Mail has only a global automatic check setting, on only a limited number of intervals. I have several accounts, some of which are not urgent, some of which get a lot of spam, and some which I'd like to check often, without have to wait for all others to check, and some of which I use only for sending, so I don't want to check them at all.
This is a feature I really missed from other email clients like Eudora. To try to duplicate this behavior, I set Mail to Manual checks and created an AppleScript to check accounts at arbitrary intervals. First I ran the following script to get a list of all accounts with an integer for each, formatted in a readable way.
--get list of accounts to assign to theAccountList variable
tell application "Mail"
set theAccountList to "set theAccountList to ¬" & return & "{¬" & return as string
set theAccounts to accounts
set theAccountCount to count of theAccounts
set theSeperator to ","
set theCount to 0
repeat with eachAccount in theAccounts
set theCount to theCount + 1
if theCount = theAccountCount then
set theSeperator to ""
end if
set theString to name of eachAccount as string
set theLine to "{account \"" & theString & "\" of application \"Mail\", 0 }" & theSeperator & " ¬"
set theAccountList to theAccountList & theLine & return
end repeat
set theAccountList to theAccountList & "}" & return
display dialog "Account List:" default answer theAccountList
end tell
(*
Paste the result from the above script into the following script and set minute intervals for accounts (with 0 to indicate no check). This script can be saved as an application and run as long as you want to check. It can also be added to the Mail script folder (~/Library/Scripts/Applications/Mail), though it has no facility for stopping if you run it from the script menu.
*)
tell application "Mail"
set theMinimumInterval to 0
--paste result of previous script here and set intervals
set theAccountList to ¬
{¬
{account "work" of application "Mail", 5}, ¬
{account "personal" of application "Mail", 20}, ¬
{account "spamtrap" of application "Mail", 180}, ¬
{account "sending-account" of application "Mail", 0} ¬
}
--end paste area
set theCount to 0
repeat with eachAccount in theAccountList
set theInterval to item 2 of eachAccount
if theInterval ≠ 0 then
set theCount to theCount + 1
if (theCount > 1) then
set theMinimumInterval to my gcd(theInterval, theMinimumInterval)
else
set theMinimumInterval to (theInterval as integer)
end if
end if
end repeat
if theMinimumInterval = 0 then
display dialog "No accounts have been set to check (values greater than 0)."
return
end if
set theMinuteCount to 0
repeat
delay (theMinimumInterval * 60)
set theMinuteCount to theMinuteCount + theMinimumInterval
repeat with eachAccount in theAccountList
set theAccount to item 1 of eachAccount
set theInterval to item 2 of eachAccount
if theInterval ≠ 0 then
set theMod to theMinuteCount mod theInterval
if (theMod = 0) then
check for new mail for theAccount
end if
end if
end repeat
end repeat
end tell
on gcd(a, b)
repeat until b = 0
set x to b
set b to a mod b
set a to x
end repeat
return a
end gcd
-- applescript page