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 usingset("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 :
- How can I encrypt the inline images.
- How to set internet headers when there are inline images in the body of the mail.