0

var outlook = Application("Microsoft Outlook");

Then what, the documentation is so bad. I have tried to use a number of ways to expore the object using .Account and .account and .Accounts and returning and trying JSON_Stringify to explore but no dice.

Ideally i want to be able to list all the Accounts on the system (part im stuck), use this to then ask for a selection (which I can easily do at the moment) and then pass the input into a new message .make()

koconder
  • 151
  • 7
  • JXA is junk. Stick to AppleScript, which has a lot more documentation and community experts who can help out, and get a copy of [Script Debugger](https://latenightsw.com/) which has terrific tools for exploring applications’ scripting interfaces. – foo Jan 06 '19 at 12:39
  • Thanks for the comment, JXA is more junk than AppleScript standard im aware. But part of a script I needed to work with a number of data formats where I needed to parse files natively in the script. As a non Objective-C developer using JXA's JSON and other file formats native to JS was my way forward. Seems like Script Debugger dose not support JXA :( – koconder Jan 06 '19 at 23:21
  • Nothing supports JXA, including Apple. I tried, but gave up as it was obvious they didn’t give a crap. If JavaScript’s your thing, then use Node.js. You should be able to [call AppleScript handlers directly](http://appscript.sourceforge.net/asoc.html) via its nodobjc bridge. OTOH, if working in AppleScript, SD also provides good AppleScript-ObjC/Cocoa tooling. For reading and writing JSON, use `NSJSONSerialization` (e.g. pre-wrapped implementation in my old [Web library](https://github.com/hhas/applescript-stdlib)). – foo Jan 07 '19 at 02:37

1 Answers1

0

Here is a quick and dirty JXA that just sends the name to console.log.

mail = Application('Microsoft Outlook')

mail.exchangeAccounts().forEach(function(acct) {
  console.log(acct.name()); 
} );
mail.imapAccounts().forEach(function(acct) {
  console.log(acct.name()); 
} );
mail.popAccounts().forEach(function(acct) {
  console.log(acct.name()); 
} );
mail.ldapAccounts().forEach(function(acct) {
  console.log(acct.name()); 
} );