Entourage click Account Settings New Exchange

Hi

I am trying to create a script to automatically click Entourage, Account Settings, New, then from the drop down Exchange. I have got this so far ut i am having problems on the New drop down box and Exchange

activate application “Microsoft Entourage”
tell application “System Events”
tell process “Microsoft Entourage”
click menu item “Account Settings…” of menu 1 of menu bar item “Entourage” of menu bar 1
end tell
end tell

please help

thanks

Hi,

Entourage has a hugh AppleScript dictionary.
Is GUI scripting really needed?

unfortunately yes. I have created a very long complicated script which i managed to get from a template but it doesn’t always work setting up the account. The original script works when i do it but i get errors

System Events got an error. Can’t make name of current user into type reference

part is

tell application “System Events”
set shortName to name of current user
set fullName to full name of current user
end tell

I have used the User Template to create plists and Microsoft user data to stop the registration and welcome screens but i am finding users still can’t do the simple create new exchange account from the drop down and type in their email.

So its easier if i can make this script simpler

the full script is

(*


Entourage Exchange Setup 2.0
©2008 William Smith
mecklists@comcast.net

This script may be freely modified for personal or commercial
purposes but may not be republished for profit without prior consent.

If you find this script useful or have ideas for improving it, please let me know.
It should be compatible with both Entourage 2004 and 2008, including Kerberos support.

Thank you, Kristen Dietiker, for reporting a bug in Entourage 2008
where SSL for LDAP will always be enabled. I have tweaked the account
creation to honor the correct setting.

Thank you, Don Montalvo, for your suggestion to include
a seventh E-mail example for user short name.

This script assists a user with the setup of his Exchange account
information.

  1. Customize the network and server properties below with information
    appropriate to your network.

  2. Customize the format of your company’s email addresses.

  3. Save this script as an application and store it in a location where
    any user can double-click it to set up his own email account.
    Entourage should not yet be running when this script is run.

This script assumes the user’s full name is in the form of “Last, First”,
but is easily modified if the full name is in the form of “First Last”.
It works especially well if the Mac is bound to Active Directory where
the user’s short name will match his login name.

*)


– Begin network and server properties

property useKerberos : true
– Set this property to true only if using Entourage 2008
– and Macs in your environment are bound to Active Directory.
– Kerberos support works only if your network is properly configured.

property kerberosDomainName : “xxx”
– For most Kerberos environments the Kerberos domain name
– will be the same as the E-mail domain name. This property is used
– only if the userKerberos property above is true.

property domainName : “xxx.com
– example: “domain.com

property WindowsDomain : “xxx”
– example: “DOMAIN”

property ExchangeServer : “xxx”
– example: “ExchangeServer.domain.com

property ExchangeServerSSL : false
– If Exchange users will connect to a backend server
– within the same network then SSL is probably not required.
– OWA connections will probably require SSL and this setting should be set to true.

property ExchangeServerSSLPort : 80
– If ExchangeServerSSL is false set the port to 80.
– If ExchangeServerSSL is true set the port to 443.
– Use a different port number only if specified by your administrator.

property PublicFolderServer : “xxx/public/”
– example : “FreeBusyServer.domain.com/public/

property PublicFolderServerSSL : false
– If Exchange users will connect to a backend server
– within the same network then SSL is probably not required.
– OWA connections will probably require SSL and this setting should be set to true.

property PublicFolderServerSSLPort : 80
– If PublicFolderServerSSL is false set the port to 80.
– If PublicFolderServerSSL is true set the port to 443.
– Use a different port number only if specified by your administrator.

property LDAPServer : “xxx”
– example: “GlobalCatalogServer.domain.com

– OWA connections can not use the OWA address.

property LDAPRequiresAuthentication : true
– This will almost always be true. The LDAP server in a Windows network
– will be a Global Catalog server, which is separate from the Exchange Server.
– OWA connections can not use the OWA address with this setting.

property LDAPServerSSL : false
– If Exchange users will connect to a backend server
– within the same network then SSL is probably not required.
– OWA connections can not use the OWA address with this setting.

property LDAPServerSSLPort : 3268
– If LDAPServerSSL is false set the port to 3268.
– If LDAPServerSSL is true set the port to 3269.
– Use a different port number only if specified by your administrator.

– OWA connections can not use the OWA address with this setting.

property LDAPMaximumResults : 1000
– When searching the Global Address list, this number determines
– the maximum number of entries to display.

property LDAPSearchBase : “”
– example: “cn=users,dc=domain,dc=com”

– Search base will be optional in many environments and its
– format will vary greatly. Experiment first connecting without
– entering the search base information.

property scheduled : false
– Exchange accounts don’t require that the “Send & Receive All” schedule be enabled.
– Change this setting to true if the user will also be connecting to POP or IMAP accounts.

property errorMessage : “Setup of your account failed. Please contact your workstation administrator for assistance.”
– Customize this error message for your users if their account setup fails


– End server properties


– Begin get user name

– user information is pulled from the account settings of the current user account

tell application “System Events”
set shortName to name of current user
set fullName to full name of current user
end tell


– End get user name


– Begin email address properties

– Email address formats vary between organizations.
– Seven common examples are give below but only one should be used.
– The rest should be commented out by adding "-- " to the beginning of the line.
– Your email address format may differ from all of these. If so,
– you’ll need to determine the proper script syntax and add your own entry.

– example 1: first.last@domain.com if full name displays as “Last, First”
– set emailAddress to word 2 of fullName & “.” & word 1 of fullName & “@” & domainName

– example 2: first.last@domain.com if full name displays as “First Last”
set emailAddress to word 1 of fullName & “.” & word 2 of fullName & “@” & domainName

– example 3: first@domain.com if full name displays as “First Last”
– set emailAddress to word 1 of fullName & “@” & domainName

– example 4: first@domain.com if full name displays as “Last, First”
– set emailAddress to word 2 of fullName & “@” & domainName

– example 5: flast@domain.com if full name displays as “First Last”
– set emailAddress to character 1 of word 1 of fullName & word 2 of fullName & “@” & domainName

– example 6: flast@domain.com if full name displays as “Last, First”
– set emailAddress to character 1 of word 2 of fullName & word 1 of fullName & “@” & domainName

– example 7: short@domain.com
– set emailAddress to shortName & “@” & domainName


– End email address properties


– Begin setup check

– Is Entourage already configured? This section checks for the existence
– of an Exchange Server account already in Entourage. It assumes that
– users will have only one Exchange Server account.

tell application “Microsoft Entourage”
if (exists of Exchange account 1) is true then
set theAnswer to display dialog “Entourage is already configured with an email account. Are you sure you want to set up another email account?” buttons {“Yes”, “No, just use Entourage”} default button {“No, just use Entourage”} with icon 2 with title “Alert!”
if button returned of theAnswer is “No, just use Entourage” then
display dialog “OK. Next time you can just launch Microsoft Entourage directly.” buttons {“OK”} default button {“OK”} with icon 1 with title “For your information…”
return – exits the script
end if
end if
end tell


– End setup check


– Begin account setup

try

set verifyEmail to display dialog "Please verify that your  email address is correct." default answer emailAddress with icon 2 buttons {"Cancel", "OK"} default button {"OK"}
set emailAddress to text returned of verifyEmail

set verifyServer to display dialog "Please verify that your Exchange Server name is correct." default answer ExchangeServer with icon 2 buttons {"Cancel", "OK"} default button {"OK"}
set ExchangeServer to text returned of verifyServer

tell application "Microsoft Entourage"
	activate
	set newExchangeAccount to make new Exchange account with properties {name:"Mailbox - " & fullName, Exchange ID:shortName, domain:WindowsDomain, full name:fullName, email address:emailAddress, search base:LDAPSearchBase, Exchange server settings:{address:ExchangeServer, requires SSL:ExchangeServerSSL, port:ExchangeServerSSLPort}, public folder server settings:{address:PublicFolderServer, requires SSL:PublicFolderServerSSL, port:PublicFolderServerSSLPort}, LDAP server settings:{address:LDAPServer, LDAP requires authentication:LDAPRequiresAuthentication, requires SSL:LDAPServerSSL, port:LDAPServerSSLPort, maximum entries:LDAPMaximumResults}}
	
	-- This line corrects a bug in Entourage 2008 where the SSL setting for the LDAP server
	-- will always be enabled. The property chosen above will be honored.
	
	set LDAP requires authentication of newExchangeAccount to LDAPRequiresAuthentication
	
	-- The following lines enable Kerberos support only if Entourage 2008 is installed
	-- and the userKerberos property above is set to true.
	
	if version contains "12" and useKerberos is true then
		set requires Kerberos of newExchangeAccount to useKerberos
		set principal of newExchangeAccount to useKerberos
	end if
	
	try
		close window "Entourage Setup Assistant"
	end try
	
	set enabled of schedule "Send & Receive All" to scheduled
	
end tell

on error

display dialog errorMessage with icon 2 buttons {"OK"} default button {"OK"}

end try


– End account setup

you can get long and short user name without System Events


set {short user name:shortName, long user name:fullName} to (system info)

I can’t immagine that you are not able to setup any account without GUI scripting,
for example Entourage has a Exchange address book class

The error message of System Events could come from nested application tell blocks

thanks that works great now :slight_smile: