OfficeDev/Outlook-Add-in-Store-Custom-Properties-On-Exchange-Server

Name: Outlook-Add-in-Store-Custom-Properties-On-Exchange-Server

Owner: Office Developer

Description: This sample shows how to set a property on an email message and then store that property on your Exchange server so that you can retrieve it the next time the item is returned.

Created: 2015-08-19 18:13:31.0

Updated: 2018-05-17 21:55:55.0

Pushed: 2017-12-28 21:35:16.0

Homepage: null

Size: 1327

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Outlook-Add-in-Store-Custom-Properties-On-Exchange-Server

This sample shows how to set a property on an email message and then store that property on your Exchange server so that you can retrieve it the next time the item is returned. For example, if your mail add-in for Outlook adds contacts to an external contacts database, you can set a property on an item to show that a contact was added so that you are not prompted to add the same contact a second time.

The loadCustomPropertiesAsync method on the item object returns a CustomProperties object that contains and manages the custom properties that you've stored for an item. After you loaded the custom properties, you can do the following:

You must call the saveAsync method to store the properties on the Exchange server; otherwise, all the changes that you made are discarded when the current item is changed.

The sample UI has three pages: one to set the key and value of a custom property, one to retrieve the value of a custom property, and one to remove custom properties or to persist the changes that you make to the Exchange server.

The JavaScript file contains click handlers for buttons in the UI to get, set, remove, and save custom properties by using the corresponding methods on the CustomProperties object. A local Boolean variable, customPropertiesAreLoaded, is set in the callback function for the loadCustomPropertiesAsync method to show that the custom properties object is loaded. The handlers check this value to make sure that the CustomProperties object is available before calling functions on the object.

Prerequisites

This sample requires that you have the following:

Key components of the sample

The sample solution contains the following files:

Configure the sample

The mail add-in will be activated on any email message in the user's Inbox. You can make it easier to test the add-in by sending one or more email messages to your test account before you run the sample.

Build the sample

Press F5 to build and deploy the sample application. Complete the following tasks to deploy the application:

  1. Connect to an Exchange account by providing the email address and password for an Exchange 2013 server.
  2. Allow the server to configure the email account.

Run and test the sample

You run and test the sample in the web browser that is started by Visual Studio when you build and deploy the sample.

If you are running the sample on an Exchange server that is using the default self-signed certificate, you will receive a certificate error when the web browser starts. After you verify that the web browser is opening the correct URL by looking at the web address, you can click Continue to this Web site to start Outlook Web App.

Follow these steps to run the sample:

  1. Log on to the email account by entering the account name and password.
  2. Select a message in the Inbox.
  3. Wait for the App bar to appear over the message.
  4. In the App bar, click Custom Properties.
  5. When the Custom Properties mail add-in appears, type a property name and value into the text boxes and then click the Save button to save the property value.
  6. Click Get, type a property name, and then click the Get button to retrieve a property.
  7. Click Manage, and either click Persist to save the stored properties to the Exchange server, or type a property name and click Remove to delete the property from storage.

Troubleshooting

The following are common errors that can occur when you use Outlook Web App to test a mail add-in for Outlook:

Additional resources

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.