I have managed to open a new outlook mail item from c# code successfully using the following:
using Outlook = Microsoft.Office.Interop.Outlook;
Outlook.Application oApp;
Outlook.Inspectors oInspects;
Outlook._MailItem oMailItem;
oApp = new Outlook.Application();
oInspects = oApp.Inspectors;
oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
oMailItem.Display(true);
my problem is as follows: when I click on the X in the corner of the mailitem window in order to close it, I receive a message asking if I want to save changes, which is OK. but after selecting the option "no", the email window closes but another one seems to appear right behind it (greyed out) and I have to click again on the X in the corner to close it.
the same happens if I click on the send button to send the email. the original window closes and then another window exactly the same (with all the content) appears but the buttons are greyed out and I have to click on the X in order to close it
I have tried to close the window using the following code (any combination of the lines below) but nothing seems to work:
oMailItem.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard);
oMailItem.Delete();
Marshal.FinalReleaseComObject(oMailItem);
Marshal.ReleaseComObject(oApp);
if anyone has an idea on how to solve this I would greatly appreciate it. I have been busting my head for hours looking for an answer
thanks in advance