<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style='font-size:14px; line-height:115%; color:#333; font-family:"Open Sans", Arial, Helvetica, sans-serif; font-weight:300; text-align:left' align="left"><div style="white-space:normal">
<p dir="auto" style="clear:both; font-size:14px; margin-bottom:12px; color:#333">Microsoft has this script description language called AdaptiveCards. Cortana uses it to send you potential todos based on analysis of your email conversations. It's actually remarkably useful. It will catch things where you told someone you'd look at something, or where someone promised to get something to you. And then it presents a form in your email to add them to your todos, or mark them completed. (Separately, I have a convoluted path to get Office365 todos into OmniFocus).</p>
<p dir="auto" style="clear:both; font-size:14px; margin-bottom:12px; color:#333">But of course it only works in Outlook. But it's actually useful enough that I pop over to my phone to read the Cortana messages there.</p>
<p dir="auto" style="clear:both; font-size:14px; margin-bottom:12px; color:#333">However, someone has done a loadable interpreter. You can load the card, render it, and then update the HTML with the results.</p>
<p dir="auto" style="clear:both; font-size:14px; margin-bottom:12px; color:#333">the process looks something like:</p>
<pre style="background-color:#fafafa; padding:1em; text-align:left" bgcolor="#fafafa" align="left"><code><script src="https://unpkg.com/adaptivecards/dist/adaptivecards.min.js"></script>
<script type="text/javascript">
        card = {JSON ADAPTIVECARD GOES HERE};
        var adaptiveCard = new AdaptiveCards.AdaptiveCard();
        adaptiveCard.parse(card);
        var renderedCard = adaptiveCard.render();
        document.body.appendChild(renderedCard);
</script>
</code></pre>
<p dir="auto" style="clear:both; font-size:14px; margin-bottom:12px; color:#333">See <a href="https://www.npmjs.com/package/adaptivecards" style="color:#3498db">https://www.npmjs.com/package/adaptivecards</a> for details.</p>
<p dir="auto" style="clear:both; font-size:14px; margin-bottom:12px; color:#333">But in the incoming email for Outlook, of course it doesn't use that script, because it assumes builtin support. Instead it has a script block in the HTML head with the JSON in it.</p>
<p dir="auto" style="clear:both; font-size:14px; margin-bottom:12px; color:#333"><script type="application/adaptivecard+json"><br>
JSON BLOCK<br>
</script></p>
<p dir="auto" style="clear:both; font-size:14px; margin-bottom:12px; color:#333">So what I'm wondering is whether it would be possible to write a generic bit of Javascript that finds that script, interprets the body, and then replaces the HTML section with the rendered results.  Or, maybe safer in the face of parsing errors, inserts it at the top and leaves the old HTML at the bottom.</p>
<p dir="auto" style="clear:both; font-size:14px; margin-bottom:12px; color:#333">And then we could take that and insert it into MailMate's HTML template.</p>

</div></div>
</body>
</html>