outlook - Check exchange connectivity status -


i want check if exchange server configured outlook account available before proceeding script. currently, don't check , if there's connectivity issue script hang forever on line

set m_objns = m_objoutlook.getnamespace("mapi") 

and appear unresponsive.

if there's no way within outlook api, there way retrieve exchange server address , ping or set 20 second timeout on .getnamespace function?

update: if there's problem network adapter (like if it's disabled), code can access namespace object. exchange mode 400 until there's prompt authorise code , user accepts it. however, if there's real (non-test purpose issue) exchange server down (destination host unreachable), outlook idle in state "trying connect" , can't access .session object or mapi.

there must way tell if server down.

excel can return status series of values. can if else respond status in different ways. notably if "trying connect" reports it's disconnected (300) @ least in outlook 2010.

here code return value (msgbox in there ease of testing). reference values in comments of code available here: http://msdn.microsoft.com/en-us/library/office/ff868474(v=office.14).aspx

sub checkexchangestatus() 'olcachedconnecteddrizzle    olcachedconnectedfull   olcachedconnectedheaders    olcacheddisconnected    olcachedoffline oldisconnected  olnoexchange    oloffline   olonline '600                           700                      500                         400                     200             300             0               100         800   dim olapp new outlook.application  dim olnamespace outlook.namespace   set olnamespace = olapp.getnamespace("mapi")  dim exchangestatus  olexchangeconnectionmode   exchangestatus = olnamespace.exchangeconnectionmode  msgbox (exchangestatus)  end sub 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -