0

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()
sleeper
  • 518
  • 4
  • 9
  • This is a very tough question❗️ It should be easy, but, unless I'm missing something obvious, it is not. I've done a bit of testing, and have posted some questions on a couple of JXA boards, so maybe we'll get an answer. – JMichaelTX Oct 19 '17 at 03:13

1 Answers1

1

Here's an example:

msgID = 76 // example
var outlook = Application("Microsoft Outlook");
outlook.messages.byId(msgID).open()
jackjr300
  • 7,111
  • 2
  • 15
  • 25
  • Many, many thanks !!! It's working properly. Out of curiosity, how do you managed to find this? I was unable to find any documentation related to this. – sleeper Oct 20 '17 at 06:53
  • I started with this AppleScript `tell application "Microsoft Outlook" to current messages` to get the id of the selected message, the result is **{message id 76 of application "Microsoft Outlook"}**. So as it already gave me the **ID**, I got the answer of your question from the result of this JavaScript's command `Application("Microsoft Outlook").currentMessages()`. – jackjr300 Oct 21 '17 at 18:00
  • 1
    Documentation: Search for "ID" in JavaScript for Automation Release Notes. It gives an example of the standard .byId() selector. – houthakker Oct 28 '17 at 05:36