How can I tell Outlook which email account I want it to use?

OSX 10.10.4
MS Outlook for Mac 2011

I have two different email accounts set up in Outlook. How can I tell AppleScript to send email from one particular account? So far it always defaults to the primary account, and I can’t find the name of the message property that (I guess?) controls it.

Can anyone help?


Hi Walter,

Welcome to MacScripter!

Does this help:

tell application "Microsoft Outlook"
	-- The account types are:
	--  'exchange account', 'pop account', 'imap account', and 'ldap account'
	set theAccount to the first exchange account whose name is "The-name-of-the-account-you-want-to-use"
	set theMessage to make new outgoing message with properties {account:theAccount}
	open theMessage
end tell


You magnificent fellow you, that works perfectly!

Thanks so much!

Thanks Walter.
Glad to hear it helped. :slight_smile:

I can not get my Gmail accounts to work using this for Outlook 365/2019 16.44 - Do you know what needs to be fixed or updated?

Well, that is what a default account is :slight_smile:

Your gmail account isn’t an exchange account so it would be filtred out by the above. Does your gmail account work otherwise?

If so, try and identify it in a script:

tell application "Microsoft Outlook"
	name of account 2

end tell

Then use that for your account property.

I’m trying to do the same also and pulling my hair out.

Mockman I tried your “name of account” approach for 1 and 2 and in both instances got “Microsoft Outlook got an error: Can’t get account 1”

Any ideas?

My outlook is set up with 2 Google accounts and I need to be able to switch between them.

Thanks in advance.

I don’t use Outlook, but I know that the user’s security policy is tighter on newer operating systems.

You need to 1) open the Internet Accounts pane in the System Preferences application, 2) drag (manually) the accounts you want to activate (for you Mac machine) from the right side of the window to the left side.

The dragging will enable (unlock) them for your Mac OS.

Then click on your dragged iCloud accounts one by one and set the checkbox for This action will enable to use them correctly.

This manual actions is not scriptable for user’s security.

Hey - thanks for the reply. I’m not sure that this would be the issue given that Outlook already has access to my Gmail and calendar - I use it daily for my email and calendar Mgmt of my Gmail accounts.

However I did look to try this… I don’t see what you mean by “drag (manually)”. In the Internet Accounts screen I have a list on the left of the active accounts and then a list of different providers on the right that I can click to start the setup process accordingly. I was not able to drag one of the provider logos from the right to the left. Is there something I’m missing?

I did click the Google account on the right and follow the process, giving my Mac access to the Calendar (it now shows up in the Mac Calendar app). I tried running the script again and still no joy - it detects no accounts.

I also tried running the following script to see if I was looking for the right type of account and again I got 0 results:

tell application "Microsoft Outlook"
	set email_accounts to {}
	repeat with emailAccount in imap accounts
		set end of email_accounts to (full name of emailAccount) & ":" & (email address of emailAccount)
	end repeat
	repeat with emailAccount in exchange accounts
		if exchange type of emailAccount is equal to primary account then
			set end of email_accounts to (full name of emailAccount) & ":" & (email address of emailAccount)
		end if
	end repeat
	repeat with emailAccount in pop accounts
		set end of email_accounts to (full name of emailAccount) & ":" & (email address of emailAccount)
	end repeat
	repeat with emailAccount in ldap accounts
		set end of email_accounts to (full name of emailAccount) & ":" & (email address of emailAccount)
	end repeat
end tell

Explain this point because I can’t understand. Are you saying that granting access to Mac you further check the effect in Why is nothing said about granting access to

Which version of Outlook are you using?

estockly - using version 16.63 in “old” mode so that I can still use AppleScript.

KniazidisR - I tried to give access to my Mac calendar app to gmail just so that something on my Mac had access granted in that internet accounts window. There was no option to provide outlook with access there. It does that within Outlook itself.


FYI, I ran the script in #9 above and it returned my Exchange account correctly with no errors. That’s the only account I have. I’m running Outlook v16.65 (Applescriptable) on Catalina.


Thanks kerlflooey.

It seems it works fine with everything else other than gmail accounts. My work Mac has an exchange through outlook, will try adding my gmail to that and seeing what comes back. It’s really odd.

So I checked this out and it still seems that gmail accounts don’t show up with this script.

Adding an exchange account it found it and worked. Seems the only way to interact with gmail is if the account is the default.