Office.DecryptedMessageAttachment interface
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Represents an attachment in a decrypted message.
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
To learn how to develop an encryption add-in in Outlook, see Create an encryption Outlook add-in.
Examples
// This sample handles the OnMessageRead event to decrypt the body and attachments of a message.
function onMessageReadHandler(event) {
// Your code to decrypt the contents of a message would appear here.
...
// Use the results from your decryption process to display the decrypted contents of the message body and attachments.
const decryptedBodyContent = "<p>Please find attached the recent report and its supporting documentation.</p>";
const decryptedBody = {
coercionType: Office.CoercionType.Html,
content: decryptedBodyContent
};
// Decrypted content and properties of a file attachment.
const decryptedPdfFile = "JVBERi0xLjQKJeLjz9MKNCAwIG9i...";
const pdfFileName = "Fabrikam_Report_202509";
// Decrypted content and properties of a mail item.
const decryptedEmailFile = "VGhpcyBpcyBhIHRleHQgZmlsZS4=...";
const emailFileName = "Fabrikam_Report_202508.eml";
// Decrypted properties of a cloud attachment.
const cloudFilePath = "https://contosostorage.com/reports/weekly_forecast.xlsx";
const cloudFileName = "weekly_forecast.xlsx";
// Decrypted content and properties of an inline image.
const decryptedImageFile = "iVBORw0KGgoAAAANSUhEUgAA...";
const imageFileName = "banner.png";
const imageContentId = "image001.png@01DC1DD9.1A4AA300";
const decryptedAttachments = [
{
attachmentType: Office.MailboxEnums.AttachmentType.File,
content: decryptedPdfFile,
isInline: false,
name: pdfFileName
},
{
attachmentType: Office.MailboxEnums.AttachmentType.Item,
content: decryptedEmailFile,
isInline: false,
name: emailFileName
},
{
attachmentType: Office.MailboxEnums.AttachmentType.Cloud,
isInline: false,
name: cloudFileName,
path: cloudFilePath
},
{
attachmentType: Office.MailboxEnums.AttachmentType.File,
content: decryptedImageFile,
contentId: imageContentId,
isInline: true,
name: imageFileName
}
];
event.completed(
{
allowEvent: true,
emailBody: decryptedBody,
attachments: decryptedAttachments,
contextData: { messageType: "ReplyFromDecryptedMessage" }
}
);
}
Properties
| attachment |
Specifies the type of attachment. |
| content | Specifies the Base64-encoded content of the attachment. |
| content |
Specifies the content identifier of an inline attachment. The |
| is |
If true, specifies that the decrypted attachment appears as an image in the body of the message instead of in the attachment list. If the |
| name | Specifies the name of the attachment. |
| path | Specifies the URL reference path of the attachment if its type is |
Property Details
attachmentType
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Specifies the type of attachment.
attachmentType: MailboxEnums.AttachmentType;
Property Value
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
content
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Specifies the Base64-encoded content of the attachment.
content: string;
Property Value
string
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
Important: The content property isn't supported by attachments of type MailboxEnums.AttachmentType.Cloud.
contentId
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Specifies the content identifier of an inline attachment.
The contentId property must be specified if isInline is set to true.
contentId?: string;
Property Value
string
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
Important: When images are added to a message as inline attachments, they're automatically assigned a content ID. In the body of a message, the content ID of an inline attachment is specified in the src attribute of the <img> element (for example, <img width=96 height=96 id="Picture_1" src="cid:image001.png@01DC1E6F.FC7C7410">). To easily identify and provide these inline attachments during decryption, we recommend saving the content IDs of inline attachments to the message header during encryption. Call Office.context.mailbox.item.getAttachmentsAsync to get the content ID of an inline attachment. Then, call Office.context.mailbox.item.internetHeaders.setAsync to save the ID to the header of the message.
isInline
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
If true, specifies that the decrypted attachment appears as an image in the body of the message instead of in the attachment list. If the isInline property isn't specified, its value is set to false.
isInline?: boolean;
Property Value
boolean
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
name
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Specifies the name of the attachment.
name: string;
Property Value
string
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read
path
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Specifies the URL reference path of the attachment if its type is MailboxEnums.AttachmentType.Cloud. The path property must be specified for attachments of type MailboxEnums.AttachmentType.Cloud.
path?: string;
Property Value
string
Remarks
Minimum permission level: read/write item
Applicable Outlook mode: Message Read