Skip to content

Instantly share code, notes, and snippets.

@joegasper
Last active November 27, 2023 19:28
Show Gist options
  • Save joegasper/89ec25d06f22a950d1b37a0d672dff74 to your computer and use it in GitHub Desktop.
Save joegasper/89ec25d06f22a950d1b37a0d672dff74 to your computer and use it in GitHub Desktop.
Gets internet headers on a message in Read mode.
name: Get internet headers
description: Gets internet headers on a message in Read mode.
host: OUTLOOK
api_set: {}
script:
content: |
$("#run").click(run);
function run() {
Office.context.mailbox.item.getAllInternetHeadersAsync(function(asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
console.log("Internet headers received successfully");
if (asyncResult.value.match(/^From:.*/gim)) {
console.log("From: " + asyncResult.value.match(/^From:.*/gim)[0].slice(6));
} else {
console.log("Didn't receive header for From");
}
if (asyncResult.value.match(/^To:.*/gim)) {
console.log("To: " + asyncResult.value.match(/^To:.*/gim)[0].slice(4));
} else {
console.log("Didn't receive header for To");
}
if (asyncResult.value.match(/^Reply-To:.*/gim)) {
console.log("Reply-To: " + asyncResult.value.match(/^Reply-To:.*/gim)[0].slice(10));
} else {
console.log("Didn't receive header for Reply-To");
}
if (asyncResult.value.match(/^x-sender:.*/gim)) {
console.log("x-sender: " + asyncResult.value.match(/^x-sender:.*/gim)[0].slice(10));
} else {
console.log("Didn't receive header for x-sender");
}
if (asyncResult.value.match(/^Return-Path:.*/gim)) {
console.log("Return-Path: " + asyncResult.value.match(/^Return-Path:.*/gim)[0].slice(13));
} else {
console.log("Didn't receive header for Return-Path");
}
if (asyncResult.value.match(/^x-mailer:.*/gim)) {
console.log("x-mailer: " + asyncResult.value.match(/^x-mailer:.*/gim)[0].slice(10));
} else {
console.log("Didn't receive header for x-mailer");
}
if (asyncResult.value.match(/^X-PHISHTEST:.*/gim)) {
console.log("X-PHISHTEST: " + asyncResult.value.match(/^X-PHISHTEST:.*/gim)[0].slice(10));
} else {
console.log("Didn't receive header for X-PHISHTEST");
}
} else {
console.log("Error getting internet headers: " + JSON.stringify(asyncResult.error));
}
});
}
/* Sample output:
From: [email protected]
To: [email protected]
Reply-To: [email protected]
x-sender: [email protected]
Return-Path: bounce-584609-user@[email protected]
x-mailer: ActiveCampaign Mailer
*/
language: typescript
template:
content: "<section class=\"ms-font-m\">\n\t<p>Get select internet headers on a message in Read mode.</p>\n\t<p><b>Required mode</b>: Message Read</p>\n</section>\n<section class=\"samples ms-font-m\">\n\t<h3>Try it out</h3>\n\t<button id=\"run\" class=\"ms-Button\">\n <span class=\"ms-Button-label\">Run</span>\n </button>\n</section>"
language: html
style:
content: |-
section.samples {
margin-top: 20px;
}
section.samples .ms-Button, section.setup .ms-Button {
display: block;
margin-bottom: 5px;
margin-left: 20px;
min-width: 80px;
}
language: css
libraries: |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js
[email protected]/dist/css/fabric.min.css
[email protected]/dist/css/fabric.components.min.css
[email protected]/client/core.min.js
@types/core-js
[email protected]
@types/[email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment