Get and set item data in a compose form in Outlook

Learn how to get or set various properties of an item in an Outlook add-in in a compose scenario, including its recipients, subject, body, and appointment location and time.

Getting and setting item properties for a compose add-in

In a compose form, you can get most of the properties that are exposed on the same kind of item as in a read form (such as attendees, recipients, subject, and body), and you can get a few extra properties that are relevant in only a compose form but not a read form (body, bcc).

For most of these properties, because it's possible that an Outlook add-in and the user can be modifying the same property in the user interface at the same time, the methods to get and set them are asynchronous. Table 1 lists the item-level properties and corresponding asynchronous methods to get and set them in a compose form. The item.itemType and item.conversationId properties are exceptions because users cannot modify them. You can programmatically get them the same way in a compose form as in a read form, directly from the parent object.

Other than accessing item properties in the Office JavaScript API, you can access item-level properties using Exchange Web Services (EWS). With the read/write mailbox permission, you can use the mailbox.makeEwsRequestAsync method to access EWS operations, GetItem and UpdateItem, to get and set more properties of an item or items in the user's mailbox.

The makeEwsRequestAsync method is available in both compose and read forms. For more information about the read/write mailbox permission, and accessing EWS through the Office Add-ins platform, see Understanding Outlook add-in permissions and Call web services from an Outlook add-in.

Table 1. Asynchronous methods to get or set item properties in a compose form

Property Property type Asynchronous method to get Asynchronous methods to set
bcc Recipients Recipients.getAsync Recipients.addAsync, Recipients.setAsync
body Body Body.getAsync Body.prependAsync, Body.setAsync, Body.setSelectedDataAsync
cc Recipients Recipients.getAsync Recipients.addAsync Recipients.setAsync
end Time Time.getAsync Time.setAsync
location Location Location.getAsync Location.setAsync
optionalAttendees Recipients Recipients.getAsync Recipients.addAsync Recipients.setAsync
requiredAttendees Recipients Recipients.getAsync Recipients.addAsync Recipients.setAsync
start Time Time.getAsync Time.setAsync
subject Subject Subject.getAsync Subject.setAsync
to Recipients Recipients.getAsync Recipients.addAsync Recipients.setAsync

See also