Use Applescript to send email from Outlook delegation

I am trying to write an Applescript that will send an email from Outlook on behalf of an account in which I am assigned as a delegate. I have access to send emails from this account within Outlook, but I can’t figure out how to adjust my script below to find the exchange account related to this other account that I have access to.

When I run the script below, I get the following error:

“Microsoft Outlook got an error: Can’t find exchange account 1 whose name = "delegate.name@company.com". Invalid index.” number -1719

set recipientAddress to "email@company.com"
set theSubject to "This is the subject"
set theContent to "This is only a test"

tell application "Microsoft Outlook"
	set theAccount to the first exchange account whose name is "delegate.name@company.com"
	set newMessage to make new outgoing message with properties {account:theAccount, subject:theSubject, content:theContent}
	tell newMessage
		make new recipient at newMessage with properties {email address:{address:recipientAddress}}
	end tell
	save in drafts
end tell

Run following code, and find correct presentation of account you need.


tell application "Microsoft Outlook" to return exchange accounts

then use this instead of whose … (following isn’t real code)

set theAccount to “exact presentation of what you found from code line above”