Mail.app refuses to set accounts online
What causes mail to go offline is authentication errors.  You must contact whomever is in charge of your mail authentication servers and ask them to resolve the issue. At my work mail going offline is almost considered normal due to the fact that our internet access must pass through our network proxies which often cause mail connections to fail authentication.