0

I have created Outlook web addin using office JS. This add-in encrypts/decrypts the mail and its attachments. The sender can encrypt the mail while sending the mail. The receiver can decrypt that encrypted mail.

  • For encryption, I am using HTML body of the mail.
  • When the sender adds the inline image in the email body, It will be added in body as below. When I am getting the HTML body, I am getting as below.
<img src="https://attachment.outlook.live.net/owa/MSA%3Awin23%40outlook.com/service.svc/s/GetAttachmentThumbnail?id=&thumbnailType=2&isc=1&token=&X-OWA-CANARY=&owa=outlook.live.com&scriptVer=20230428009.16&animation=true" 
     class="ContentPasted0 w-126 h-110" 
     originalsrc="cid:f4e15c67-85fa-4e94-8ba1-02f3c6fb13fc" 
     size="386" 
     contenttype="image/png">
  • Above HTML body will be sent encrypted by the sender.
  • When receiver tries to decrypt the mail by clicking add-in button, Whole content is decrypted. But image is showing crashed/broken in the right add-in panel of the outlook.

This the flow I have developed to send the mail encrypted.

  • Get body : mail_item.body.getAsync('html', function (body_get_response) {});
  • Call API to encrypt the content of the mail HTML
  • mail_item.loadCustomPropertiesAsync(function (get_property_response) {}); to set properties using set("key","value") method.
  • Setting headers using mail_item.internetHeaders.setAsync({"key":"value"}, function (set_headers_response) {});
  • mail_item.saveAsync(function (save_mail_response) {}); to save the mail with internet headers and properties.
  • mail_item.body.setAsync(encrypted_body, { coercionType: Office.CoercionType.Html }, function (body_set_response) {}); to set the body.

But I came to know that, When I am adding inline image to the outlook mail body, The internet headers are not setting and mail_item.internetHeaders.setAsync({"key":"value"}, function (set_headers_response) {}); giving below error :

Sys.ArgumentTypeException: Object of type 'object' cannot be converted to type 'string'.
Parameter name: internetHeaders

So basically, I am having two issues :

  1. How can I encrypt the inline images.
  2. How to set internet headers when there are inline images in the body of the mail.
Smit Rathod
  • 101
  • 6
  • Thanks for sharing the details. We are not able to repro this issue at our end, could you please help us with a test add-in that we can use to repro this scenario? Please email the details at this address: OutlookExtensibility@M365x27035562.onmicrosoft.com. Thanks! – Outlook Add-ins Team - MSFT May 16 '23 at 06:02
  • @Outlook Add-ins Team - MSFT I have resolved this. I came to know that my exchange certificate was expired. I have renewed it. Now I am able to set headers. But my 2nd question is still not resolved. Thanks for response. – Smit Rathod May 16 '23 at 06:13
  • Thanks for confirming this. By 2nd question, are you referring to the "How can I encrypt the inline images." question? – Outlook Add-ins Team - MSFT May 17 '23 at 03:29
  • @Outlook Add-ins Team - MSFT Yes, That's correct. While encrypting inline image, I am getting one URL on which image is hosted. I am getting `https://attachment.outlook.live.net/owa/MSA%3Aemail%40outlook.com/service.svc/s/GetAttachmentThumbnail?id=XYZId&thumbnailType=2&isc=1&token=XYZToken&X-OWA-CANARY=HeaderValue&owa=outlook.live.com&scriptVer=20230505004.14&animation=true`. Mails are encrypting successfully, But when I am trying to decrypt those, I am getting same URL. But this time, Token has been expired & I am getting '440 Login Timed Out'. – Smit Rathod May 17 '23 at 05:14
  • @Outlook Add-ins Team - MSFT I have tried to convert inline images to base64 string while encrypting, But mail body came with too lengthy content. So is there any way to get those images while decrypting messages. – Smit Rathod May 17 '23 at 05:15
  • Hi @Smit, we won't be able to help you directly here as encryption is not supported through any OfficeJS API. – Outlook Add-ins Team - MSFT May 19 '23 at 09:47

0 Answers0