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”
For anyone like myself who is looking for a solution to this problem in 2026 I ran a separate AppleScript to find the exact name off the account
tell application "Microsoft Outlook"
set allAccounts to {}
-- Get Exchange accounts
try
set exchangeAccounts to get exchange accounts
repeat with acc in exchangeAccounts
set end of allAccounts to "Exchange: " & name of acc & " (" & user name of acc & ")"
end repeat
on error
-- Handle potential errors if no Exchange accounts exist or scripting is blocked
end try
-- Display the list of accounts
if allAccounts is not {} then
display dialog "Found Accounts:" & return & return & (allAccounts as string)
else
display dialog "No Outlook accounts found or could be accessed via AppleScript."
end if
end tell
then used the name of the account I needed
set theAccount to first exchange account whose name is "account.name"
set newMessage to make new outgoing message with properties {account:theAccount, subject:theSubject, content:theBody}