Search code examples
outlookapplescriptjavascript-automation

JXA .- How to open a mail based on ID in Outlook


I'm stumbling on a simple issue but cannot manage to wrap my head around and make it work. I'm trying using JAX to open a mail in Outlook based on it's ID. I know that with AppleScript it's dead easy:

tell application "Microsoft Outlook"
    open message id msgID
    activate
end tell

But I've no clue how to transform it in Javascript:

var outlook = Application("Microsoft Outlook");
outlook.includeStandardAdditions = true;
message = ???? <-- Don't know how to select the message with ID mID
message.open()

Solution

  • Here's an example:

    msgID = 76 // example
    var outlook = Application("Microsoft Outlook");
    outlook.messages.byId(msgID).open()