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

Avoid 'Working Offline' issues in Mail.app Apps
I've always been bothered by Mail.app's "Working Offline" mode. I have two email accounts -- one for my domain and one for Gmail. If the POP server for one of them (or my network connection) goes down, Mail fails silently and won't check that account for new mail until I manually bring that account back online.

I finally wrote an AppleScript to get around this annoying problem.

Open up Script Editor and paste in the following code:
on checkall()
  tell application "Mail"
    repeat with each_account in every account
      tell each_account
        check for new mail for each_account
      end tell
    end repeat
  end tell
end checkall

on isrunning()
  tell application "System Events" to 
    set mail_running to (exists process "Mail")
  return mail_running
end isrunning

on runloop()
  repeat
    if isrunning() then checkall()
    
    delay 1 * minutes
    -- change this number to how often you want to
    --check all of your accounts for new mail.
  end repeat
end runloop

runloop()
Choose Save As... from the File menu. Change 'File Format' to Application Bundle, make sure that none of the checkboxes are checked, and save the file into your Home folder or your Applications folder (well, anywhere, for that matter). Call it "Mail Checker" (or something like that). Just make sure you remember where you save it.

Now, in the Finder, go to where you just saved that file. Hold down the Control key and click on it. Choose "Show Package Contents," and a new Finder window appears. In the new window, open the "Contents" folder and open "info.plist" in TextEdit, or a text editor of your choice. After the opening <dict> tag, add the following two lines:
<key>NSUIElement</key>
<string>1</string>
Now save the file. This step simply makes the dock icon for the application hidden -- you don't want to have an application icon appear in your dock every time it checks for new mail. Close the document window and the "Contents" finder window, but leave the other Finder window (containing the Mail Checker script) open.

Now, you need to make this script run each time you login on your computer. The following instructions are for Panther only. Go to System Preferences and open the Accounts pane. Choose the Startup Items tab. Drag the Mail Checker script from the Finder to the list box in the Startup Items tab. It doesn't matter where it is in the list, or if the hide box is checked. Quit System Preferences.

To keep Mail's automatic checking from conflicting with this script's automatic checking, you need to turn Mail's off. Go into Mail preferences, General pane. Change "Check for new mail" to "Manually." Close the prefs window.

Now you're ready to launch the script and behold its amazing offline-overriding abilities! Double-click its icon in the Finder, and enjoy!

[robg adds: I haven't tested this one.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[18,851 views]  

Avoid 'Working Offline' issues in Mail.app | 16 comments | Create New Account
Click here to return to the 'Avoid 'Working Offline' issues in Mail.app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Avoid 'Working Offline' issues in Mail.app
Authored by: leenoble_uk on Mar 01, '05 09:16:23AM

Whatever happened to using links like this?.

---
So, I said ... well, I can't actually remember exactly what I said. But it was one of the most enormously cruel and frighteningly witty put downs ever.

[ Reply to This | # ]

Avoid 'Working Offline' issues in Mail.app
Authored by: restiffbard on Mar 01, '05 09:18:16AM

dude, that was freaking cool. I had no idea that even existed.



[ Reply to This | # ]
For anyone interested
Authored by: bonkydooky on Mar 01, '05 11:20:15AM
That type of linking is documented here.

[ Reply to This | # ]
Avoid 'Working Offline' issues in Mail.app
Authored by: jctull on Mar 01, '05 02:05:01PM

Whenever I click the "Manually Check Email" icon in my toolbar, it will attempt to bring any offline accounts back online. I do this all the time when I switch from wired to wireless, and Mail.app checks before I have connected to my wireless network. Once I get my network connection in order, I manually check mail and all is good again.



[ Reply to This | # ]
NOT silently
Authored by: germ on Mar 01, '05 03:43:26PM

A small, gray "broken connection" icon appears near the In mailbox in the mailbox drawer.



[ Reply to This | # ]
It's useful!
Authored by: fluffyx on Mar 01, '05 07:42:38PM

I keep Mail hidden and use Mail.appetizer to tell me when I have new mail... As I never look at Mail's main window until I'm notified of a mail, I miss the Working Offline indicators. So this proves quite useful :-).



[ Reply to This | # ]
Avoid 'Working Offline' issues in Mail.app
Authored by: genericuser on Mar 01, '05 09:55:00PM

Kind of off topic...

Can anyone tell me how to check with AppleScript if your computer is connected to the Internet?

---
Bugmenot public account



[ Reply to This | # ]
Avoid 'Working Offline' issues in Mail.app
Authored by: sphere on Mar 01, '05 11:59:36PM

Great Hint. I have been looking for something to do this for a long time



[ Reply to This | # ]
Previous hint
Authored by: sinjin on Mar 02, '05 06:56:14PM
Yes, this has been covered here. Other than searching past hints (note search option towards upper right corner of window) you can also ask these sorts of questions in the "Forums".

[ Reply to This | # ]
Avoid 'Working Offline' issues in Mail.app
Authored by: ld on Mar 02, '05 09:47:39PM

If you're anything like me and have a few alias email addresses (i.e., e.g., yahoo alias addresses which help to protect your real address) then adjusting your accounts and the script to only work with 'legit' accounts is desirable.

Step 1: Adjust your account Display Names
change your account display names so that they either end in " POP" or " IMAP" etc. Note the space before each ending. These will be used to identify legitimate from illigitimate accounts

e.g., Open Preferences > Accounts and selecct an account from the list. If you had an account called "Yahoo Mail" change its Description to "Yahoo Mail POP"

Step 2: Use the following script and then follow the steps outlined by the original poster


property LegitEndingTypes : {" POP", " IMAP"}
property IsDebug : false

my runloop()

on runloop()
	repeat
		if my isMailRunning() then my checkLegitAccounts()
		if IsDebug then exit repeat
		delay 10 * minutes
		-- change this number to how often you want to
		--check all of your accounts for new mail.
	end repeat
end runloop

on isMailRunning()
	tell application "System Events" to 
		set isMailRunning to (exists process "Mail")
	return isMailRunning
end isMailRunning

on checkLegitAccounts()
	tell application "Mail"
		repeat with anAccount in every account
			if (my isLegitAccount(name of anAccount)) then
				tell anAccount
					check for new mail for anAccount
				end tell
			end if
		end repeat
	end tell
end checkLegitAccounts

on isLegitAccount(aName)
	considering case
		repeat with aType in LegitEndingTypes
			if (aName ends with aType) then return true
		end repeat
	end considering
	return false
end isLegitAccount

---
regards,
LD

[ Reply to This | # ]

Avoid 'Working Offline' issues in Mail.app
Authored by: rawhead on Mar 03, '05 04:34:29AM

Arrgh!

This works, which is great, because I've wanted something like this since 10.0. Seriously, I told good old Cricket on several occasions on the OSX list that Mail.app has to (a) get rid of those intrusive alert windows that come to the fore everytime it can't connect to the mail server, and (b) for cryin' out loud don't go to "offline mode" and stay there when it can't connect to the mail server.

Sadly, neither of these issues has been addressed after so many iterations of OSX/Mail.app.

The bad news is that, because this script is a "force check" of e-mail (the equivalent of clicking on the check mail icon), Mail blurts out that very annoryingly high-pitched whining sound (You've got mail.... NOT!) sound every time it checks mail.... which I want it to do every 1 minute, just like in the original script.

I guess this is where <a href="http://www.macosxhints.com/article.php?story=20031029112821812&query=mail+sound">this hint</a> comes in handy.

---
All these moments will be lost in time
Like tears in rain.
Time to die.



[ Reply to This | # ]
Avoid 'Working Offline' issues in Mail.app
Authored by: rawhead on Mar 03, '05 04:38:22AM
Forgot to turn on "HTML formatting". Heh. THIS is the hint.

---
All these moments will be lost in time
Like tears in rain.
Time to die.

[ Reply to This | # ]

Trun off alerts
Authored by: sinjin on Mar 03, '05 12:44:02PM
If you don't like Mail's alerts you can turn them off in the Preferences. Or if your issue is that you want the alerts under other circumstances but not when this script runs you can use these lines in the script to toggle alert sounds off:

	set new mail sound to none
	set should play other mail sounds to false
and on:

	set new mail sound to someannoyingsound
	set should play other mail sounds to true


[ Reply to This | # ]
Trun off alerts
Authored by: rawhead on Mar 04, '05 01:16:38AM

>>If you don't like Mail's alerts you can turn them off in the Preferences

Yeah, as you say, I want sounds played for other instances, like mail sent (swooooosh!). Just not every 1 minute that Mail goes looking for new messages and can't find any.


---
All these moments will be lost in time
Like tears in rain.
Time to die.



[ Reply to This | # ]
Trun off alerts
Authored by: leenoble_uk on Mar 04, '05 12:11:01PM

Do a search on the interweb for an application called Play Sound. It's free and all it does is play sounds.

Then turn off all your Mail sounds and save this script to your ~/Library/scripts/Mail Scripts folder.

Make a new rule in Mail for every message to run by this script. This way you get a sound for each new message. Kind of annoying when you have 60 odd to download but at least you can hear not only when you have messages but how many you have.

---
So, I said ... well, I can't actually remember exactly what I said. But it was one of the most enormously cruel and frighteningly witty put downs ever.

[ Reply to This | # ]

Avoid 'Working Offline' issues in Mail.app
Authored by: ephramz on Mar 06, '05 02:36:03PM
Great script, I was just looking for something like this having this problem regularly with 3 different accounts. One thing, I've heard that delay steals CPU cycles so
		do shell script "sleep 60"
might be better than
                delay 1*minutes
for the rest period of the script. The unix command sleep takes the number of seconds to sleep for.

[ Reply to This | # ]