Office.MessageRead interface
The message read mode of Office.context.mailbox.item.
Important:
This is an internal Outlook object, not directly exposed through existing interfaces. You should treat this as a mode of
Office.context.mailbox.item. For more information, refer to the Object Model page.When calling
Office.context.mailbox.itemon a message, note that the Reading Pane in the Outlook client must be turned on. For guidance on how to configure the Reading Pane, see Use and configure the Reading Pane to preview messages.
Parent interfaces:
- Extends
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml
const item = Office.context.mailbox.item;
if (item.attachments.length > 0) {
for (let i = 0; i < item.attachments.length; i++) {
const attachment = item.attachments[i];
console.log(`${i+1}. Name: ${attachment.name}`);
console.log(`ID: ${attachment.id}`);
console.log(`Type: ${attachment.attachmentType}`);
console.log(`Inline content: ${attachment.isInline}`);
console.log(`Size: ${attachment.size}`);
}
} else {
console.log("This mail item doesn't contain any attachments.");
}
Properties
| attachments | Gets the item's attachments as an array. |
| body | Gets an object that provides methods for manipulating the body of an item. |
| cc | Provides access to the Cc (carbon copy) recipients of a message. The type of object and level of access depend on the mode of the current item. The
|
| conversation |
Gets an identifier for the email conversation that contains a particular message. You can get an integer for this property if your mail app is activated in read forms or responses in compose forms. If subsequently the user changes the subject of the reply message, upon sending the reply, the conversation ID for that message will change and that value you obtained earlier will no longer apply. You get null for this property for a new item in a compose form. If the user sets a subject and saves the item, the |
| date |
Gets the date and time that an item was created. |
| date |
Gets the date and time that an item was last modified. |
| end | Gets the date and time that the appointment is to end. The When you use the |
| from | Gets the email address of the sender of a message. The Note: The The |
| internet |
Gets the internet message identifier for an email message. Important: In the Sent Items folder, the |
| item |
Gets the Exchange Web Services item class of the selected message. |
| item |
Gets the Exchange Web Services (EWS) item identifier of the current item. |
| item |
Gets the type of item that an instance represents. The |
| location | Gets the location of a meeting request. The |
| normalized |
Gets the subject of an item, with all prefixes removed (including RE: and FWD:). The |
| sender | Gets the email address of the sender of an email message. The Note: The |
| start | Gets the date and time that the appointment is to begin. The |
| subject | Gets the description that appears in the subject field of an item. The The |
| to | Provides access to the recipients on the To line of a message. The type of object and level of access depend on the mode of the current item. The
|
Methods
| display |
Displays a reply form that includes either the sender and all recipients of the selected message or the organizer and all attendees of the selected appointment. |
| display |
Displays a reply form that includes only the sender of the selected message or the organizer of the selected appointment. |
| get |
Gets the entities found in the selected item's body. Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. We recommend updating your contextual add-in to use regular expression rules as an alternative solution. For guidance on how to implement these rules, see Contextual Outlook add-ins. |
| get |
Gets an array of all the entities of the specified entity type found in the selected item's body. Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. We recommend updating your contextual add-in to use regular expression rules as an alternative solution. For guidance on how to implement these rules, see Contextual Outlook add-ins. |
| get |
Returns well-known entities in the selected item that pass the named filter defined in an add-in only manifest file. Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. We recommend updating your contextual add-in to use regular expression rules as an alternative solution. For guidance on how to implement these rules, see Contextual Outlook add-ins. |
| get |
Returns string values in the selected item that match the regular expressions defined in an add-in only manifest file. |
| get |
Returns string values in the selected item that match the named regular expression defined in an add-in only manifest file. |
| load |
Asynchronously loads custom properties for this add-in on the selected item. Custom properties are stored as key-value pairs on a per-app, per-item basis. This method returns a CustomProperties object in the callback, which provides methods to access the custom properties specific to the current item and the current add-in. Custom properties aren't encrypted on the item, so this shouldn't be used as secure storage. The custom properties are provided as a |
Property Details
attachments
Gets the item's attachments as an array.
attachments: AttachmentDetails[];
Property Value
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Important:
Certain types of files are blocked by Outlook due to potential security issues and are therefore not returned. For more information, see Blocked attachments in Outlook.
Attachments added using the Upload and share option aren't returned.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/40-attachments/get-attachments-read.yaml
const item = Office.context.mailbox.item;
if (item.attachments.length > 0) {
for (let i = 0; i < item.attachments.length; i++) {
const attachment = item.attachments[i];
console.log(`${i+1}. Name: ${attachment.name}`);
console.log(`ID: ${attachment.id}`);
console.log(`Type: ${attachment.attachmentType}`);
console.log(`Inline content: ${attachment.isInline}`);
console.log(`Size: ${attachment.size}`);
}
} else {
console.log("This mail item doesn't contain any attachments.");
}
body
Gets an object that provides methods for manipulating the body of an item.
body: Body;
Property Value
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// This example gets the body of the item as plain text.
Office.context.mailbox.item.body.getAsync(
"text",
{ asyncContext: "This is passed to the callback" },
function callback(result) {
// Do something with the result.
});
// The following is an example of the result parameter passed to the callback function.
{
"value": "TEXT of whole body (including threads below)",
"status": "succeeded",
"asyncContext": "This is passed to the callback"
}
cc
Provides access to the Cc (carbon copy) recipients of a message. The type of object and level of access depend on the mode of the current item.
The cc property returns an array that contains an EmailAddressDetails object for each recipient listed on the Cc line of the message. The maximum number of recipients returned varies per Outlook client.
classic Windows: 500 recipients
Android, classic Mac UI, iOS: 100 recipients
Web browser, new Outlook: 20 recipients (collapsed view), 500 recipients (expanded view)
New Mac UI: No limit
cc: EmailAddressDetails[];
Property Value
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-cc-message-read.yaml
const msgCc = Office.context.mailbox.item.cc;
console.log("Message copied to:");
for (let i = 0; i < msgCc.length; i++) {
console.log(msgCc[i].displayName + " (" + msgCc[i].emailAddress + ")");
}
conversationId
Gets an identifier for the email conversation that contains a particular message.
You can get an integer for this property if your mail app is activated in read forms or responses in compose forms. If subsequently the user changes the subject of the reply message, upon sending the reply, the conversation ID for that message will change and that value you obtained earlier will no longer apply.
You get null for this property for a new item in a compose form. If the user sets a subject and saves the item, the conversationId property will return a value.
conversationId: string;
Property Value
string
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-conversation-id-message.yaml
console.log(`Conversation ID: ${Office.context.mailbox.item.conversationId}`);
dateTimeCreated
Gets the date and time that an item was created.
dateTimeCreated: Date;
Property Value
Date
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-created-read.yaml
console.log(`Creation date and time: ${Office.context.mailbox.item.dateTimeCreated}`);
dateTimeModified
Gets the date and time that an item was last modified.
dateTimeModified: Date;
Property Value
Date
Remarks
Minimum permission level: read item
Applicable Outlook mode: Appointment Attendee
Important: This property isn't supported in Outlook on Android or on iOS. For more information on supported APIs in Outlook mobile, see Outlook JavaScript APIs supported in Outlook on mobile devices.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-date-time-modified-read.yaml
console.log(`Date and time item last modified: ${Office.context.mailbox.item.dateTimeModified}`);
end
Gets the date and time that the appointment is to end.
The end property is a Date object expressed as a Coordinated Universal Time (UTC) date and time value. You can use the convertToLocalClientTime method to convert the end property value to the client's local date and time.
When you use the Time.setAsync method to set the end time, you should use the convertToUtcClientTime method to convert the local time on the client to UTC for the server.
end: Date;
Property Value
Date
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-end-read.yaml
const time = Office.context.mailbox.item.end;
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
console.log(`Appointment ends (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
from
Gets the email address of the sender of a message.
The from and sender properties represent the same person unless the message is sent by a delegate. In that case, the from property represents the delegator, and the sender property represents the delegate.
Note: The recipientType property of the EmailAddressDetails object in the from property is undefined.
The from property returns an EmailAddressDetails object.
from: EmailAddressDetails;
Property Value
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-from-message-read.yaml
const msgFrom = Office.context.mailbox.item.from;
console.log("Message received from: " + msgFrom.displayName + " (" + msgFrom.emailAddress + ")");
internetMessageId
Gets the internet message identifier for an email message.
Important: In the Sent Items folder, the internetMessageId may not be available yet on recently sent items. In that case, consider using Exchange Web Services to get this property from the server.
internetMessageId: string;
Property Value
string
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-internet-message-id-read.yaml
console.log(`Internet message ID: ${Office.context.mailbox.item.internetMessageId}`);
itemClass
Gets the Exchange Web Services item class of the selected message.
itemClass: string;
Property Value
string
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Important:
The following table lists the default item classes for messages.
| Item class | Description |
|---|---|
| IPM.Note | New messages and message replies |
| IPM.Schedule.Meeting.Request | Meeting requests |
| IPM.Schedule.Meeting.Canceled | Meeting cancellations |
| IPM.Schedule.Meeting.Resp.Neg | Responses to decline meeting requests |
| IPM.Schedule.Meeting.Resp.Pos | Responses to accept meeting requests |
| IPM.Schedule.Meeting.Resp.Tent | Responses to tentatively accept meeting requests |
You can create custom classes that extend a default item class. For example, IPM.Note.Contoso.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-class-read.yaml
console.log(`Item class: ${Office.context.mailbox.item.itemClass}`);
itemId
Gets the Exchange Web Services (EWS) item identifier of the current item.
itemId: string;
Property Value
string
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Important:
The
itemIdproperty isn't available in compose mode. If an item identifier is required, theOffice.context.mailbox.item.saveAsyncmethod can be used to save the item to the store, which will return the item identifier in theasyncResult.valueparameter in the callback function. If the item is already saved, you can call theOffice.context.mailbox.item.getItemIdAsyncmethod instead.The item ID returned isn't identical to the Outlook Entry ID or the ID used by the Outlook REST API. Before making REST API calls using this value, it should be converted using
Office.context.mailbox.convertToRestId.
Examples
// The following code checks for the presence of an item
// identifier. If the `itemId` property returns `null` or
// `undefined`, it saves the item to the store and gets the
// item identifier from the asynchronous result.
// **Important**: `saveAsync` was introduced with requirement set 1.3
// so you can't get the `itemId` in Compose mode in earlier sets.
let itemId = Office.context.mailbox.item.itemId;
if (itemId === null || itemId == undefined) {
Office.context.mailbox.item.saveAsync(function(result) {
itemId = result.value;
});
}
itemType
Gets the type of item that an instance represents.
The itemType property returns one of the ItemType enumeration values, indicating whether the item object instance is a message or an appointment.
itemType: MailboxEnums.ItemType | string;
Property Value
Office.MailboxEnums.ItemType | string
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-item-type.yaml
const itemType = Office.context.mailbox.item.itemType;
switch (itemType) {
case Office.MailboxEnums.ItemType.Appointment:
console.log(`Current item is an ${itemType}.`);
break;
case Office.MailboxEnums.ItemType.Message:
console.log(`Current item is a ${itemType}. A message could be an email, meeting request, meeting response, or meeting cancellation.`);
break;
}
location
Gets the location of a meeting request.
The location property returns a string that contains the location of the appointment.
location: string;
Property Value
string
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-location-read.yaml
console.log(`Appointment location: ${Office.context.mailbox.item.location}`);
normalizedSubject
Gets the subject of an item, with all prefixes removed (including RE: and FWD:).
The normalizedSubject property gets the subject of the item, with any standard prefixes (such as RE: and FW:) that are added by email programs. To get the subject of the item with the prefixes intact, use the subject property.
normalizedSubject: string;
Property Value
string
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-normalized-subject-read.yaml
console.log(`Normalized subject: ${Office.context.mailbox.item.normalizedSubject}`);
sender
Gets the email address of the sender of an email message.
The from and sender properties represent the same person unless the message is sent by a delegate. In that case, the from property represents the delegator, and the sender property represents the delegate.
Note: The recipientType property of the EmailAddressDetails object in the sender property is undefined.
sender: EmailAddressDetails;
Property Value
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-sender-message-read.yaml
const msgSender = Office.context.mailbox.item.sender;
console.log("Sender: " + msgSender.displayName + " (" + msgSender.emailAddress + ")");
start
Gets the date and time that the appointment is to begin.
The start property is a Date object expressed as a Coordinated Universal Time (UTC) date and time value. You can use the convertToLocalClientTime method to convert the value to the client's local date and time.
start: Date;
Property Value
Date
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-start-read.yaml
const time = Office.context.mailbox.item.start;
const localTime = Office.context.mailbox.convertToLocalClientTime(time);
console.log(`Appointment starts (local): ${localTime.month + 1}/${localTime.date}/${localTime.year}, ${localTime.hours}:${localTime.minutes}:${localTime.seconds}`);
subject
Gets the description that appears in the subject field of an item.
The subject property gets or sets the entire subject of the item, as sent by the email server.
The subject property returns a string. Use the normalizedSubject property to get the subject minus any leading prefixes such as RE: and FW:.
subject: string;
Property Value
string
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/90-other-item-apis/get-subject-read.yaml
console.log(`Subject: ${Office.context.mailbox.item.subject}`);
to
Provides access to the recipients on the To line of a message. The type of object and level of access depend on the mode of the current item.
The to property returns an array that contains an EmailAddressDetails object for each recipient listed on the To line of the message. The maximum number of recipients returned varies per Outlook client.
classic Windows: 500 recipients
Android, classic Mac UI, iOS: 100 recipients
Web browser, new Outlook: 20 recipients (collapsed view), 500 recipients (expanded view)
New Mac UI: No limit
to: EmailAddressDetails[];
Property Value
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/30-recipients-and-attendees/get-to-message-read.yaml
const msgTo = Office.context.mailbox.item.to;
const distributionLists = [];
const externalRecipients = [];
const internalRecipients = [];
const otherRecipients = [];
for (let i = 0; i < msgTo.length; i++) {
switch (msgTo[i].recipientType) {
case Office.MailboxEnums.RecipientType.DistributionList:
distributionLists.push(msgTo[i]);
break;
case Office.MailboxEnums.RecipientType.ExternalUser:
externalRecipients.push(msgTo[i]);
break;
case Office.MailboxEnums.RecipientType.User:
internalRecipients.push(msgTo[i]);
break;
case Office.MailboxEnums.RecipientType.Other:
otherRecipients.push(msgTo[i]);
}
}
if (distributionLists.length > 0) {
console.log("Distribution Lists:");
distributionLists.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`));
}
if (externalRecipients.length > 0) {
console.log("External Recipients:");
externalRecipients.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`));
}
if (internalRecipients.length > 0) {
console.log("Internal Recipients:");
internalRecipients.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`));
}
if (otherRecipients.length > 0) {
console.log("Other Recipients:");
otherRecipients.forEach((recipient) => console.log(`${recipient.displayName}, ${recipient.emailAddress}`));
}
Method Details
displayReplyAllForm(formData)
Displays a reply form that includes either the sender and all recipients of the selected message or the organizer and all attendees of the selected appointment.
displayReplyAllForm(formData: string | ReplyFormData): void;
Parameters
- formData
-
string | Office.ReplyFormData
A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB OR a ReplyFormData object that contains body or attachment data and a callback function.
Returns
void
Remarks
Minimum permission level: read item
Applicable Outlook mode: Appointment Attendee
Important:
In Outlook on the web and new Outlook on Windows, the reply form is displayed as a pop-out form in the 3-column view and a pop-up form in the 2-column or 1-column view.
If any of the string parameters exceed their limits,
displayReplyAllFormthrows an exception.When attachments are specified in the
formData.attachmentsparameter, Outlook attempts to download all attachments and attach them to the reply form. If any attachments fail to be added, an error is shown in the form UI. If this isn't possible, then no error message is thrown.This method isn't supported in Outlook on Android or on iOS. For more information on supported APIs in Outlook mobile, see Outlook JavaScript APIs supported in Outlook on mobile devices.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml
Office.context.mailbox.item.displayReplyAllForm("This is a reply ALL with <b>some bold text</b>.");
...
// Define attachments.
const base64Attachment = {
base64file:
"iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTM0A1t6AAAF3klEQVR4Xt2aMcolRRSFdQUuwSW4AAMzU8ENzAIMDA1NzHUBgqmZkbG4ADGVQRgGZBBElAERRPg9eC+PQ73qc6u66lZ3v48bzH+7uqr6VN/T1f3mjafT8Pr7b37+8G3En99+5akTcAqB/n7+48uP3vvp3TdvgT//+uE7P3woBwv07+s/Xn32jKXhwKF/Xr3wpgdxpEC/ffnp8/ffKkQpAg3QDDr6Ocs5RiCzm0ILEQca02qB7u2mPQ4xpnUCabtBWDWFdbfYmBYJ1HLZN6PBP3794uOiAcdKY0oXKLQbFE71jkBS33FrjClRoNBuXjx7J/QUNNCdZBtTikAtdtO1+JBA34Z5xjRfIG03I/YBTYVMScY0U6DQbsbXGdevF2C6Mc0RKLQbHEUbbz0MZNKPuYnGNCpQaDdY0iQTDR9zU4xpSCB9t+PQ719/7k3T0P49bkw7BQrtZnBajTS+uIwYU7dA4ZzynrhMWF/3sc+YOgQK7WaiNQpCh9bRu36tAmm7wT2MovOmaU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N70TW1ZTdVWgUCoTFh1JGK46481U9YU70fITsEMrQxjVQc9+OpTnRNhXZTpVsgI5zKjorjHjzVjK6pkWXbKZCBm1kYU2/F8bmeakDXVJfdVBkSCGB+wpi6lo5P9FSEvpF77abKqECGNqbGiuNTPLWNrikc2mE3VeYIZOj1DCuOG3uqhq6pEbupMlMgA7PfMiY9e27pqTvEGozbTZX5AgFtTFsVx208ReiammI3VVIEMrQxYbWLS+KjnvofXVMT7aZKokCGKIqi4viQp3pOTyJdIAO3wJYx3SqOk/hT1FSS3VRZJBDQxlQUkaipPLupsk4gQxuTjmy7qbJaIEM4SzXW2E2VYwQyhDHdYqXdVDlSIKCNabHdVDlYIOPemA6xmyqnEMgwYzrQbio8Pf0HxndUxitiwgUAAAAASUVORK5CYII=",
inLine: true,
name: "script_lab.png",
type: Office.MailboxEnums.AttachmentType.Base64
};
const fileAttachment = {
inLine: true,
name: "dog.jpg",
type: Office.MailboxEnums.AttachmentType.File,
url: "https://i.imgur.com/9S36xvA.jpg"
};
const itemAttachment = {
itemId: Office.context.mailbox.item.itemId,
name: "test_email.msg",
type: Office.MailboxEnums.AttachmentType.Item
};
// Create the reply with attachments.
Office.context.mailbox.item.displayReplyAllForm({
htmlBody:
"This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.<br><img src='cid:script_lab.png'><br><img src='cid:dog.jpg'>",
attachments: [base64Attachment, fileAttachment, itemAttachment],
callback: (result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(`Action failed with message ${result.error.message}`);
return;
}
console.log("Created a reply-all form with attachments.");
}
});
displayReplyForm(formData)
Displays a reply form that includes only the sender of the selected message or the organizer of the selected appointment.
displayReplyForm(formData: string | ReplyFormData): void;
Parameters
- formData
-
string | Office.ReplyFormData
A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB OR a ReplyFormData object that contains body or attachment data and a callback function.
Returns
void
Remarks
Minimum permission level: read item
Applicable Outlook mode: Message Read
Important:
In Outlook on the web and new Outlook on Windows, the reply form is displayed as a pop-out form in the 3-column view and a pop-up form in the 2-column or 1-column view.
If any of the string parameters exceed their limits,
displayReplyFormthrows an exception.When attachments are specified in the
formData.attachmentsparameter, Outlook attempts to download all attachments and attach them to the reply form. If any attachments fail to be added, an error is shown in the form UI. If this isn't possible, then no error message is thrown.This method isn't supported in Outlook on Android or on iOS. For more information on supported APIs in Outlook mobile, see Outlook JavaScript APIs supported in Outlook on mobile devices.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/55-display-items/display-reply-forms.yaml
Office.context.mailbox.item.displayReplyForm("This is a reply with <i>some text in italics</i>.");
...
// Define attachments.
const base64Attachment = {
base64file:
"iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTM0A1t6AAAF3klEQVR4Xt2aMcolRRSFdQUuwSW4AAMzU8ENzAIMDA1NzHUBgqmZkbG4ADGVQRgGZBBElAERRPg9eC+PQ73qc6u66lZ3v48bzH+7uqr6VN/T1f3mjafT8Pr7b37+8G3En99+5akTcAqB/n7+48uP3vvp3TdvgT//+uE7P3woBwv07+s/Xn32jKXhwKF/Xr3wpgdxpEC/ffnp8/ffKkQpAg3QDDr6Ocs5RiCzm0ILEQca02qB7u2mPQ4xpnUCabtBWDWFdbfYmBYJ1HLZN6PBP3794uOiAcdKY0oXKLQbFE71jkBS33FrjClRoNBuXjx7J/QUNNCdZBtTikAtdtO1+JBA34Z5xjRfIG03I/YBTYVMScY0U6DQbsbXGdevF2C6Mc0RKLQbHEUbbz0MZNKPuYnGNCpQaDdY0iQTDR9zU4xpSCB9t+PQ719/7k3T0P49bkw7BQrtZnBajTS+uIwYU7dA4ZzynrhMWF/3sc+YOgQK7WaiNQpCh9bRu36tAmm7wT2MovOmaUAaPY3G6DK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VWgUCoTFh1JGK46481U9YU70fITsEMrQxjVQc9+OpTnRNhXZTpVsgI5zKjorjHjzVjK6pkWXbKZCBm1kYU2/F8bmeakDXVJfdVBkSCGB+wpi6lo5P9FSEvpF77abKqECGNqbGiuNTPLWNrikc2mE3VeYIZOj1DCuOG3uqhq6pEbupMlMgA7PfMiY9e27pqTvEGozbTZX5AgFtTFsVx208ReiammI3VVIEMrQxYbWLS+KjnvofXVMT7aZKokCGKIqi4viQp3pOTyJdIAO3wJYx3SqOk/hT1FSS3VRZJBDQxlQUkaipPLupsk4gQxuTjmy7qbJaIEM4SzXW2E2VYwQyhDHdYqXdVDlSIKCNabHdVDlYIOPemA6xmyqnEMgwYzrQbio8Pf0HxndUxitiwgUAAAAASUVORK5CYII=",
inLine: true,
name: "script_lab.png",
type: Office.MailboxEnums.AttachmentType.Base64
};
const fileAttachment = {
inLine: true,
name: "dog.jpg",
type: Office.MailboxEnums.AttachmentType.File,
url: "https://i.imgur.com/9S36xvA.jpg"
};
const itemAttachment = {
itemId: Office.context.mailbox.item.itemId,
name: "test_email.msg",
type: Office.MailboxEnums.AttachmentType.Item
};
// Create the reply with attachments.
Office.context.mailbox.item.displayReplyForm({
htmlBody:
"This is a reply with an inline Base64-encoded attachment, an inline image, and an item attachment.<br><img src='cid:script_lab.png'><br><img src='cid:dog.jpg'>",
attachments: [base64Attachment, fileAttachment, itemAttachment],
callback: (result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(`Action failed with message ${result.error.message}`);
return;
}
console.log("Created a reply with attachments.");
}
});
getEntities()
Gets the entities found in the selected item's body.
Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. We recommend updating your contextual add-in to use regular expression rules as an alternative solution. For guidance on how to implement these rules, see Contextual Outlook add-ins.
getEntities(): Entities;
Returns
Remarks
Minimum permission level: read item
Applicable Outlook mode: Appointment Attendee
getEntitiesByType(entityType)
Gets an array of all the entities of the specified entity type found in the selected item's body.
Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. We recommend updating your contextual add-in to use regular expression rules as an alternative solution. For guidance on how to implement these rules, see Contextual Outlook add-ins.
getEntitiesByType(entityType: MailboxEnums.EntityType | string): Array<string | Contact | MeetingSuggestion | PhoneNumber | TaskSuggestion>;
Parameters
- entityType
-
Office.MailboxEnums.EntityType | string
One of the EntityType enumeration values.
Returns
Array<string | Office.Contact | Office.MeetingSuggestion | Office.PhoneNumber | Office.TaskSuggestion>
If the value passed in entityType is not a valid member of the EntityType enumeration, the method returns null. If no entities of the specified type are present in the item's body, the method returns an empty array. Otherwise, the type of the objects in the returned array depends on the type of entity requested in the entityType parameter.
Remarks
Minimum permission level: restricted
Applicable Outlook mode: Message Read
getFilteredEntitiesByName(name)
Returns well-known entities in the selected item that pass the named filter defined in an add-in only manifest file.
Warning: Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. We recommend updating your contextual add-in to use regular expression rules as an alternative solution. For guidance on how to implement these rules, see Contextual Outlook add-ins.
getFilteredEntitiesByName(name: string): Array<string | Contact | MeetingSuggestion | PhoneNumber | TaskSuggestion>;
Parameters
- name
-
string
The name of the ItemHasKnownEntity rule element that defines the filter to match.
Returns
Array<string | Office.Contact | Office.MeetingSuggestion | Office.PhoneNumber | Office.TaskSuggestion>
The entities that match the regular expression defined in the ItemHasKnownEntity rule element in the add-in manifest file with the specified FilterName element value. If there's no ItemHasKnownEntity element in the manifest with a FilterName element value that matches the name parameter, the method returns null. If the name parameter matches an ItemHasKnownEntity element in the manifest, but there are no entities in the current item that match, the method returns an empty array.
Remarks
Minimum permission level: read item
Applicable Outlook mode: Appointment Attendee
getRegExMatches()
Returns string values in the selected item that match the regular expressions defined in an add-in only manifest file.
getRegExMatches(): any;
Returns
any
An object that contains arrays of strings that match the regular expressions defined in the add-in manifest file. The name of each array is equal to the corresponding value of the RegExName attribute of the matching ItemHasRegularExpressionMatch rule. For an ItemHasRegularExpressionMatch rule, a matching string has to occur in the property of the item that's specified by that rule. The PropertyName simple type defines the supported properties.
Remarks
Minimum permission level: read item
Applicable Outlook mode: Appointment Attendee
Important:
Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. We recommend updating your contextual add-in to use regular expression rules as an alternative solution. For guidance on how to implement these rules, see Contextual Outlook add-ins.
This method is used with the activation rules feature for Outlook add-ins, which isn't supported by the unified manifest for Microsoft 365.
If you specify an
ItemHasRegularExpressionMatchrule on the body property of an item, the regular expression should further filter the body and shouldn't attempt to return the entire body of the item. Using a regular expression such as.*to obtain the entire body of an item doesn't always return the expected results. Instead, use theBody.getAsyncmethod to retrieve the entire body.This method isn't supported in Outlook on Android or on iOS. For more information on supported APIs in Outlook mobile, see Outlook JavaScript APIs supported in Outlook on mobile devices.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml
// This API only works when you click on the highlighted word "ScriptLab".
console.log(Office.context.mailbox.item.getRegExMatches());
getRegExMatchesByName(name)
Returns string values in the selected item that match the named regular expression defined in an add-in only manifest file.
getRegExMatchesByName(name: string): string[];
Parameters
- name
-
string
The name of the ItemHasRegularExpressionMatch rule element that defines the filter to match.
Returns
string[]
An array that contains the strings that match the regular expression defined in the ItemHasRegularExpressionMatch rule element in the add-in manifest file, with the specified RegExName element value.
Remarks
Minimum permission level: read item
Applicable Outlook mode: Appointment Attendee
Important:
Entity-based contextual Outlook add-ins are now retired. However, regular expression rules are still supported. We recommend updating your contextual add-in to use regular expression rules as an alternative solution. For guidance on how to implement these rules, see Contextual Outlook add-ins.
This method is used with the activation rules feature for Outlook add-ins, which isn't supported by the unified manifest for Microsoft 365.
If you specify an
ItemHasRegularExpressionMatchrule on the body property of an item, the regular expression should further filter the body and shouldn't attempt to return the entire body of the item. Using a regular expression such as.*to obtain the entire body of an item doesn't always return the expected results. Instead, use theBody.getAsyncmethod to retrieve the entire body.This method isn't supported in Outlook on Android or on iOS. For more information on supported APIs in Outlook mobile, see Outlook JavaScript APIs supported in Outlook on mobile devices.
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/75-regex-matches/contextual.yaml
// This API only works when you click on the highlighted word "ScriptLab".
console.log(Office.context.mailbox.item.getRegExMatchesByName("sampleRegexName"));
loadCustomPropertiesAsync(callback, userContext)
Asynchronously loads custom properties for this add-in on the selected item.
Custom properties are stored as key-value pairs on a per-app, per-item basis. This method returns a CustomProperties object in the callback, which provides methods to access the custom properties specific to the current item and the current add-in. Custom properties aren't encrypted on the item, so this shouldn't be used as secure storage.
The custom properties are provided as a CustomProperties object in the asyncResult.value property. This object can be used to get, set, save, and remove custom properties from the mail item.
loadCustomPropertiesAsync(callback: (asyncResult: Office.AsyncResult<CustomProperties>) => void, userContext?: any): void;
Parameters
- callback
-
(asyncResult: Office.AsyncResult<Office.CustomProperties>) => void
When the method completes, the function passed in the callback parameter is called with a single parameter of type Office.AsyncResult.
- userContext
-
any
Optional. Developers can provide any object they wish to access in the callback function. This object can be accessed by the asyncResult.asyncContext property in the callback function.
Returns
void
Remarks
To learn more about custom properties, see Get and set add-in metadata for an Outlook add-in.
Minimum permission level: read item
Applicable Outlook mode: Message Read
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/outlook/15-item-custom-properties/load-set-get-save.yaml
Office.context.mailbox.item.loadCustomPropertiesAsync((result) => {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error(`loadCustomPropertiesAsync failed with message ${result.error.message}`);
return;
}
customProps = result.value;
console.log("Loaded the CustomProperties object.");
});