开发者

VSTO - Outlook 2007 - Display form before send message?

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

I want to display a pop-up form (or selection) and ask for user input at the time they click Send. Basically, whenever they send out an email (New or Reply), they will be asked to select a value in a dropdown box (list items from a SQL database, preferrably). Base on their selection, a text message will be appended to the mail's subject.

I did my research and it looks like I should use Form Regions but I'm not sure how can I display a popup/extra form when user click Send. Also, it looks like Form Regions can be used to extend/replace current VIEW mail form but can I use it for CRE开发者_C百科ATE NEW form?

Thanks for everybody's time.


You can probably add the Item Send event handler in the ThisAddIn Internal Startup method and then in the Item Send Event, call the custom form (a windows form). In the below sample I call a custom windows form as modal dialog before the email item is send and after the send button is clicked.

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;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜