VSTO - Outlook 2007 - Show form before sending message?

I am new to programming the Outlook add-in and not sure if this is possible:

I want to display a pop-up window (or a choice) and request user input at the moment the "Submit" button is clicked. Basically, whenever they send an email ("New" or "Reply"), they will be asked to select a value from the drop-down list (list items from the SQL database, preferably). Based on their selection, a text message will be added to the subject line.

I did my research, and it looks like I should use Form Regions, but I'm not sure how I can display pop-up / additional forms when the user clicks Submit. Also, it looks like Form Regions can be used to expand / replace the current VIEW email form, but can I use it for the CREATE NEW form?

Thanks for all the time.

+5
source share
1 answer

, ThisAddIn, , ( ). .

private void InternalStartup()
{
    this.Application.ItemSend += new ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
}

void Application_ItemSend(object Item, ref bool Cancel)
{
    if (Item is Microsoft.Office.Interop.Outlook.MailItem)
    {
        Microsoft.Office.Interop.Outlook.MailItem currentItem = Item as Microsoft.Office.Interop.Outlook.MailItem; 
        Cancel = true;
        Forms frmProject = new ProjectForm();;

        DialogResult dlgResult = frmProject.ShowDialog();

        if (dlgResult == DialogResult.OK) 
            System.Windows.Forms.SendKeys.Send("%S"); //If dialog result is OK, save and send the email item
        else
            Cancel = false; 

        currentItem.Save();
        currentItem = null;
    }
}
+5

All Articles