2009-11-16 70 views
5

我是新來的Outlook插件程序,不知道這是可能的:VSTO - Outlook 2007 - 在發送消息之前顯示錶單?

我想顯示一個彈出窗體(或選擇),並在他們點擊發送時要求用戶輸入。基本上,每當他們發出一封電子郵件(新建或回覆)時,他們都會被要求在下拉框中選擇一個值(最好從SQL數據庫中列出項目)。 根據他們的選擇,郵件的主題將附加一條短信。

我做了我的研究,它看起來像我應該使用窗體區域,但我不知道當用戶單擊發送時如何顯示彈出式窗體/額外窗體。 另外,它看起來像表單區域可以用來擴展/替換當前的VIEW郵件表單,但我可以使用CREATE NEW表單嗎?

感謝大家的時間。

回答

5

您可以在ThisAddIn內部啓動方法中添加Item Send事件處理程序,然後在Item Send Event中調用自定義窗體(窗體)。 在下面的示例中,我在電子郵件項目發送之前和發送按鈕被單擊之後,將自定義窗體稱爲模態對話框。

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; 
    } 
} 
相關問題