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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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:
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:
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.