Skip to content

Instantly share code, notes, and snippets.

@davecra
Created May 24, 2019 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davecra/6b2eaa49555bc631c51a845b1a2c3f9a to your computer and use it in GitHub Desktop.
Save davecra/6b2eaa49555bc631c51a845b1a2c3f9a to your computer and use it in GitHub Desktop.
Sample demonstrating use of simpleMIMEClass
function sampleOfficeEvent(event){
/** @type {Office.Types.ItemCompose} */
var item = Office.cast.item.toItemCompose(Office.context.mailbox.item);
item.saveAsync(function(idResult) {
easyEws.getMailItemMimeContent(idResult.value,
function(mimeResult) {
/** {@type (simpleMIMEClass)} */
var oMime = new simpleMIMEClass();
oMime.Parse(mimeResult);
var doc = $(oMime.HTML()); // load into an HTML document
console.clear();
console.log("MIME: " + oMime.Text()); // get the raw MIME text
console.log("HEADER: " + oMime.FullHeader()); // get the full header info
console.log("HTML: " + oMime.HTML()); // return just the HTML
// here we are looking for the first image in the HTML document
var id = doc.find("img").attr("src");
// we display the SRC - which is a CID
console.log("TAG: " + id);
// Then we display the BASE64 string data for the image
// which can be converted to an image, replaced in the src tag
// to make it inline or store offline
console.log("DATA: " + oMime.GetImageData(id));
// done
event.completed();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment