Outlook 2011 / exchange account / is connected

Okay you legends!

I’m failing at the very first hurdle with this one.

Trying to write a script I can leave running in the background similar to the one I’ll post at the end.

What I need this one to do is return the connection status of two Exchange Accounts, and if either is offline, then restart Outlook 2011.

Now in the Dictionary i’ve found these two items :

exchange account n [inh. account > object > item] : An exchange account.
is connected (boolean, r/o) : Indicates whether an exchange account is online.

But i’ll be damned if I can work out how to tie this into something meaningful!

Any ideas?

See snippet of a script I run to check on Network Servers…

try
	repeat
		tell application "Finder"
			if exists disk "NETWORK$" then
				set nStatus to "NETWORK : ONLINE"
			else
				set nStatus to "NETWORK : OFFLINE"
				mount volume nStudio as user name nStudioUser with password nPassword
			end if
			end tell
		delay 600
	end repeat
on error
	tell application "Microsoft Outlook"
		set ErrorEmail to make new outgoing message with properties ¬
			{account:(exchange account eMailAccount), subject:eMailSubject, plain text content:eMailContent}
		make new recipient at ErrorEmail with properties {email address:{address:eMailAddress}}
		send ErrorEmail
	end tell
end try


Okay… I think I got this!

As bizarre as it seems I can’t think of a better way to do this, but effectively this script monitors Outlook 2011 and if it looks to be offline, then Mail steps in and sends a warning as well as restarting Outlook. Obviously if the network is down then nothing will send… but meh.

Feel free to pick it apart :stuck_out_tongue:


try
	repeat
		tell application "Microsoft Outlook"
			if is connected of myAccountS is true then
				set EmailStatus to "Email : ONLINE"
			else
				tell application "Mail"
					set ErrorEmail to make new outgoing message with properties {subject:eMailSubject, content:eMailContent, visible:true}
					tell ErrorEmail
						make new to recipient with properties {address:eMailAddress}
						send
						tell application "Microsoft Outlook" to quit
						delay 60
						tell application "Microsoft Outlook" to open
					end tell
				end tell
			end if
			if is connected of myAccountC is true then
				set EmailStatus to "Email : ONLINE"
			else
				tell application "Mail"
					set ErrorEmail to make new outgoing message with properties {subject:eMailSubject, content:eMailContent, visible:true}
					tell ErrorEmail
						make new to recipient with properties {address:eMailAddress}
						send
						tell application "Microsoft Outlook" to quit
						delay 60
						tell application "Microsoft Outlook" to open
					end tell
				end tell
			end if
		end tell
		delay 600
	end repeat
end try

Testing has shown that this doesn’t repeat infinitely.

Not sure how to fix that? I thought the repeat would do it :confused: