A couple of weeks ago the Office Developer Tools received its second update. These tools include the latest Office add-in project template that help you create add-ins for Excel, Word, Outlook, …
Info: The Office developer tools for Visual Studio can be found here - https://www.visualstudio.com/en-us/features/office-tools-vs.aspx
With the help of these tools, you should get up and running with Office Add-in development in no time. In fact, it was quicker in the previous version. There are a couple of things that got changed in this update. First of all, when you are going to create a new project, you will be asked which type of add-in you are going to create:
Before this update it looked as follows:
This is a good change, but let’s say if you want to create an Outlook add-in. Before you had the option to specify which type of add-in you wanted to create:
This wizard is not there anymore. The moment you create the project from the new Outlook Add-in template. It will automatically create a project with a read form add-in. You do not get the option to choose which type of add-in(s) you want to create. In my opinion, this makes things a bit tougher when you were used to what the previous version provided.
So in case, if you want to create a compose form add-in, you have to do some manual configuration to make it work.
Setting up the required files for your compose form add-in
Start by creating a new **ComposeForm **folder in your project for the compose form. This is not required, but it is cleaner to separate the forms.
Add the following files to the ComposeForm folder:
- Form.html
- Form.css
- Form.js
Form.html
Add the following code to your HTML file:
|
|
Form.js
Add the following code to your JS file:
|
|
Configuring the compose form
Now that all the required files are in place, it is time to configure the compose form to the manifest XML file.
Open the manifest file;
Find the FormSettings element;
Insert the compose form element underneath the read form;
|
|
Info: If you do not want to show the read form. You can remove the ItemRead form from the FormSettings element.
- Next is to add a new rule element. Find the Rule element in the file;
- Add a new Rule element for the Edit form type;
|
|
Info: If you do not want to show the read form. You can change the FormType to Edit instead.
At this point, you configured the compose form for Outlook Online and Outlook 2013. If you want to use the add-in in Outlook 2016 you will have to do a bit more configuration in order to get it working.
Outlook 2016 configuration - add-in commands
For Outlook 2016 you will have to configure an additional add-in command in order to load the task pane. The configuration for this need to be done in the same manifest file as where you did the previous changes.
Find the ExtensionPoint element in the manifest file. This is the add-in command which is defined for the read form.
Add a new ExtensionPoint element for your compose form with the following code:
|
|
Info: If you do not need the read form in your add-in, you best remove the ExtensionPoint for the MessageReadCommandSurface type.
The last thing to do is creating the label variable and task pane URL. Add the following highlighted lines of code to your Resources element manifest file: lines 10, 17, 18, 22.
|
|
Once this is in place, you can debug the application and you will get an add-in action that opens the compose form task pane in the Outlook 2016 client.
Resources
More information about this can be found here:
- Office Add-in Commands and SharePoint 2016 Support
- Define add-in commands in your Outlook add-in manifest
Code
I have uploaded my sample project to GitHub: Outlook add-in compose sample project