Entourage - automatically change default account

Hi

I use my computer at home and at work. At work, I have an exchange account. I am looking to automate the process whereby when I am at home, Entourage will use my home email address as the default account. While at work, it will use the exchange account. This will avoid the multiple email failure sends that I have as I shift between home and work (requiring me to manually reset the default account or alter the account on a per email basis). I have Entourage to always reply from the default account so if I can automate the changing of the default account by location, that would be good.

I have in mind a script that runs when I wake the computer from sleep which will check IP address to determine where it is and then set the default account accordingly.

A start would be how to change the Entourage default account using applescript, which I have not been able to work out yet.

Any pointers?

Cheers

I have worked out partly how to set the default account. The following script works to set my defaul POP account:

tell application "Microsoft Entourage"
		set default mail account to POP account "My Pop Account"
end tell

But I cannot get it to switch back to the Exchange account with this:

tell application "Microsoft Entourage"
		set default mail account to Exchange account "My Exchange Account"
end tell

Can anyone explain?

Cheers

Hi kiwilegal,

It looks kind of easy to do this.

First open the dictionary for Entourage:

  1. run Script Editor
  2. look in the menu for something like “open dictionary”
  3. select Microsoft Entourage from the list

this opens the AppleScript dictionary.

Now look in the dictionary for the “Application” object and select it. In the suite for class application, you’ll see ‘elements’ and properties. You want to look in the properties for something like ‘default mail account’. In my version, this is how it looks:

default mail account reference – to the default mail account

This tells you you need a reference to the mail account. If you don’t know how to reference it, look at the current example"

tell app “Microsoft Entourage”
get default mail account
end tell

When you run this in the Script Editor, it returns a result which you can see. Look for the result and this is what you would use in your script. In my version the result looks like this:

POP account id 1 of application “Microsoft Entourage”

This tells me that I can set the default account with:

tell application “Microsoft Entourage”
set default mail account to POP account id 1
end tell

If I had more then one account the second one would probably be:

tell application “Microsoft Entourage”
set default mail account to POP account id 2
end tell

Note that you cannot set all propeties of an object. Some are read only and the dictionary tells you this with the abreviation “r/o”. For instance, the ‘in box folder’ property:

in box folder reference [r/o] – to the inbox

is read only.

Now you know how to look at the dictionary at the various properties some of which may be changed and how to change them.

gl,

Hi kiwilegal,

I see that you have done it yourself. Great!

I see pop account and other account classes in the dictionary, but I don’t see exchange account. Use the example method. Manually change the account to the exchange account and look at the result of getting it.

gl,

Hi Kel

I did the get process and my Exchange account is described as “Exchange account id 2”. However, using the following code produces the same result as before (ie none).

tell application “Microsoft Entourage”
set default mail account to Exchange account id 2
end tell

I have captured errors just in case hidden errors are being thrown up but nothing gives. Curious. And the dictionary does contain Exchange account. However, while POP accounts are a class of the Entourage Mail and News suite, the Exchange account is a class from Terminology suite. Might this explain things?

Cheers

… and I now see that Exchange account appears as a class of Entourage Mail and News Suite as well…

Stumped!

I have had some success in determining IP address adapting code from another post:

set ifaddrAirport to "Not connected"
set ifaddrEthernet to "Not connected"

try
	set ifaddrAirport to do shell script "ipconfig getifaddr en1" -- check Airport
end try
try
	set ifaddrEthernet to do shell script "ipconfig getifaddr en0" -- check ethernet
end try
display dialog "Airport:  " & ifaddrAirport & return & "Ethernet: " & ifaddrEthernet with title "Internal IP Addresses"

So the pieces are there to finish this if someone can explain why I cannot reset the default account to my Exchange account.

Thanks

Thanks, Jacques.

Microsoft bug seems to have been repaired to the extent at least that you can get the default mail account when it is set to Exchange. But setting it still does not work.

I am now thinking how to work around this:)

Cheers