Skip to content

Instantly share code, notes, and snippets.

@ddacunha
Created June 20, 2018 01:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddacunha/cc0a00580648550fbd931f569245d971 to your computer and use it in GitHub Desktop.
Save ddacunha/cc0a00580648550fbd931f569245d971 to your computer and use it in GitHub Desktop.
[AppleScript] Select next message in Outlook 2016 (in Javascript)
var outlook = Application('Microsoft Outlook')
var selectedMessageList = outlook.currentMessages()
for ( m of selectedMessageList) {
console.log( "selectedMessageList: " + m.id())
}
var lastSelectedMessage = selectedMessageList[selectedMessageList.length-1] //set lastMessage to last item of msgList
console.log (lastSelectedMessage.subject())
var messagesInInbox = outlook.inbox.messages()
console.log( "Message count in Inbox: " + messagesInInbox.length)
// Find next message after selection
var nextMessage
for (var i = 0; i < messagesInInbox.length; i++) {
if( messagesInInbox[i].id() == lastSelectedMessage.id() ) {
console.log( "Found message")
nextMessage = messagesInInbox[ i + 1]
break
}
}
console.log( "Next message: " + nextMessage.id() + " subject: " + nextMessage.subject())
var account = lastSelectedMessage.account()
outlook.selection = nextMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment