Created
September 13, 2023 13:33
-
-
Save davecra/fea7f88562d93adec84610c8c9bbb537 to your computer and use it in GitHub Desktop.
JSRuntime to get it working
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks to see if we are running in Windows Outlook | |
* @returns {Boolean} | |
*/ | |
function isPC() { | |
try { | |
if (Office.context.platform === Office.PlatformType.PC || Office.context.platform === null) { | |
return true; | |
} else { | |
return false; | |
} | |
} catch { | |
return false; | |
} | |
} | |
if (isPC() === true) { | |
Office.actions.associate("onMessageSendHandler", onMessageSendHandler); | |
} else { | |
Office.onReady(function () {}); | |
// Everything below is for OTHER (non-PC) clients per older constructs. Not certain | |
// if any of this is needed except for COMMANDS (rather than EVENTS), so eventually | |
// if commands are added, we have this in place... | |
var g = getGlobal(); | |
// The add-in command functions need to be available in global scope | |
g.onMessageSendHandler = onMessageSendHandler; // on send event | |
} | |
/** | |
* OnSend event triggered | |
* @param {Office.AddinCommands.Event} event | |
*/ | |
function onMessageSendHandler(event) { | |
Office.onReady(function () {}); | |
Office.context.mailbox.item.body.getAsync(Office.CoercionType.Text, { asyncContext: event }, function (asyncResult) { | |
var body = asyncResult.value; | |
var event = asyncResult.asyncContext; | |
// ... more code here ... | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment