-1

I'm making a custom add-in for Outlook 2013/2016 and decided to implement it with a custom ribbon button. I've followed this guide which has been good so far : https://timdams.com/2017/05/09/how-to-create-a-simple-outlook-vsto-addin-a-step-by-step-guide/

The add-in simply edits the "location" field of a new meeting request or appointment and inserts a pre-defined phone number (for a conference call etc).

I've got that part working with the click of a custom button in the ribbon, but the inserted phone number is hard coded. I'd like to make it customizable and create another button that brings up a "settings page" where a user can enter in their own phone number, save it, and then the add-in will use that number instead.

I'm having trouble finding resources on how to do this. If someone could point me in the right direction that would be great.

NavMan
  • 345
  • 1
  • 5
  • 10

2 Answers2

1

You can create a regular Winform. The only trick is to make sure it is parented correctly to the right Outlook Inspector or Explorer object - cast the appropriate object to IOleWindow, then call IOleWindow.GetWindow. Once you have HWND, you can use it with the NativeWindow object and pass it to Form.ShowDialog().

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Sorry I'm quite new to VSTO development so I'm not understanding some of the terms you're using. I've got a Winform going in my project now (added as a new item), then I used the toolbox to add a text box and "save" button. Now how do I link it back to the ribbon button? – NavMan Jul 09 '19 at 04:25
  • In the event handler, create a new instance of your form's class and use NativeWindow to parent it to the correct Outlook window. – Dmitry Streblechenko Jul 09 '19 at 04:27
  • Thanks I've managed to code in the bulk of the functionality I wanted using a Winform. Although I didn't use any of the methods you suggested. I simply used the `showDialog();` method to run on the button click to bring up the new form. – NavMan Jul 11 '19 at 02:44
  • If you don't parent the form correctly, it might be possible to click on the Outlook window while you dialog is being modally shown. – Dmitry Streblechenko Jul 11 '19 at 05:00
0

I'd suggest creating an adjoining Outlook form region for such purposes. So, users could easily edit the settings for new meeting requests or appointments. See Create Outlook form regions for more information. Also, you may find the Walkthrough: Design an Outlook form region article helpful.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45