I'm currently playing around with Office 2013 Add-Ins with Visual Studio 2013. I've created a Ribbon with a Button that displays a little Windows Form:
private void outterMailCreateNewFaxBTN_Click(object sender, RibbonControlEventArgs e)
{
CreateNewFax cnf = new CreateNewFax(this);
cnf.Show();
}
When the user clicks on one of the buttons on the Form, a new MailItem is being created (with some information inside it).
private void button1_Click(object sender, EventArgs e)
{
this.Dispose();
this.outterMailRibbon.setFaxNumber(faxNumber, this);
}
Here is the setFaxNumber-Method:
public void setFaxNumber(String faxNumber, CreateNewFax cnf)
{
cnf = null;
//mother.Dispose();
this.faxNumber = faxNumber;
Outlook.Application application = Globals.ThisAddIn.Application;
Outlook.MailItem myMailItem = (Outlook.MailItem)application.CreateItem(Outlook.OlItemType.olMailItem);
myMailItem.To = this.faxNumber;
myMailItem.Subject = "[FAX:" + this.faxNumber + "]";
myMailItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain;
((Outlook.ItemEvents_10_Event)myMailItem).Send += new Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(ThisAddIn_Send);
this.gMailItem = myMailItem;
myMailItem.Display(true);
}
The problem im currently facing is that after the user clicked on the specific button on the Form the Outlook main-process is blocked and the UI freezes until the newly created Message is sent or discarded.
How can I avoid this behaviour (so that the user is able to display other Mails from outlook, while this newly created MailItem is still editable by the user)?
EDIT: The Outlook-UI freezes after the MailItem was created. At the Time, the Windows Form is still opened, Im able to use the Outlook-UI as usual.