AppleScript to create a new Outlook email using selected text as subject

applescriptautomationms office

I have a workflow that involves creating emails by copying and pasting text into the subject. I think an AppleScript could do much of the heavy lifting. I'd also use Automator to set up the input as selected text and also setup a "run applescript" part to the workflow.

So this script would essentially tell Outlook to take input (selected text) and set as subject of a new email.

I think it would start out like this, from referencing other scripts to automate email creation in outlook:

tell application "Microsoft Outlook"
set NewMail to make new outgoing message with properties

I imagine after that it would be something like {Subject: Input}

Anyone know what the proper way to do this?

Best Answer

See if this works for you:

set varSubject to "Hello"
set varContent to "GoodBye"
set varName to "Jon Snow"
set varEmail to "jsnow@castleblack.org"
tell application "Microsoft Outlook"
    set newMail to make new outgoing message with properties {subject:varSubject, plain text content:varContent}
    make new recipient at newMail with properties {email address:{name:varName, address:varEmail}}
end tell