Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Regularly synchronize IMAP folders in Mail' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Regularly synchronize IMAP folders in Mail
Authored by: jonathanlacour on Jan 20, '05 05:03:33PM
The methods listed in the above comments are inefficient. I found a script somewhere that was much more efficient and edited it a bit. Here it is. Basically, you just need to cycle the status of an IMAP account to get it to update message counts. If you synchronize its going to take a long time and traverse your entire mail hierarchy. Create an applescript that runs when you log into your computer, and this should make things a lot snappier when dealing with your server-side filtering with IMAP:

on checkMail()
	tell application "Mail"
		set everyIMAPAccount to every imap account
		repeat with eachIMAPAccount in everyIMAPAccount
			tell eachIMAPAccount
				-- cycle online status of each enabled and online account, causing mail to update the status for each folder
				if (enabled and include when getting new mail) then
					set include when getting new mail to false
					set include when getting new mail to true
				end if
			end tell
		end repeat
	end tell
end checkMail

-- Loops until the background activity of Mail has stopped
on waitForNoBackgroundActivity()
	tell application "Mail"
		repeat
			if (background activity count is equal to 0) then exit repeat
			delay 5
		end repeat
	end tell
end waitForNoBackgroundActivity

on run
	tell application "System Events"
		if exists (application processes whose name is "Mail") then
			my waitForNoBackgroundActivity()
			my checkMail()
		end if
	end tell
end run

on idle
	delay 120
	tell application "System Events"
		if not (exists (application processes whose name is "Finder")) then quit
		if exists (application processes whose name is "Mail") then
			my waitForNoBackgroundActivity()
			my checkMail()
		end if
	end tell
	return 0
end idle


[ Reply to This | # ]
Regularly synchronize IMAP folders in Mail
Authored by: sydlow on May 01, '05 03:14:36AM

What IMAP mail server are you running? This approach of cycling doesn't work for me when connecting to Communigate server on Mail.app v2 on Tiger.



[ Reply to This | # ]