Monday, July 26, 2021

#1 2021-06-15 06:59:23 pm

MalibuLX3
Member
Registered: 2021-06-15
Posts: 2

Select mailbox for Microsoft Outlook when using Applescript

I'm using Applescript to automatically draft and send emails in Microsoft Outlook.  While everything is working as expected to send emails from my own account, I want to adjust the script to send emails from a different account that I have access to in Outlook.  I've found this post, but the approach shown there generates an error for me. 

https://macscripter.net/viewtopic.php?p … 22#p185222

**How can I adjust the script below to select the correct mailbox to send my email from?** When I use the script below, the following error is generated when I attempt to save it.

Syntax Error
Expected class name but found identified



I've Google this error message, but haven't been able to find anything relevant to my task of changing the account the email is sent from.

Applescript:

set theAccount to the first exchange account whose name is "second.account@company.com"
set recipientAddress to "first.last@company.com"
set theSubject to "This is only a test"
set theContent to "<html><body><p>This is only a test.</p></body></html>"

tell application "Microsoft Outlook"
   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

Offline

 

#2 2021-06-15 10:01:20 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1954

Re: Select mailbox for Microsoft Outlook when using Applescript

the 1st code line works only telling to "Microsoft Outlook" application. Because it uses its terms.

Applescript:


tell application "Microsoft Outlook" to set theAccount to the first exchange account whose name is "second.account@company.com"


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)