I develop an outlook adding using Visual studio 2013 and Addin express v.7.7.4087. I wanting to handle the ItemSend() and save the item to drafts and close the inspector automatically, We can do everything apart from closing the inspector, because it is not allowed to close the inspector inside the method of ItemSend(), I have use a windows.forms.timer (close the mailitem inside timer) to do this but ends up with an error where it says “RCW content has been separated from …………” error
Are there any alternative ways of doing this?
In redemption (for outlook), is there a way of doing the same thing?
private void adxOutlookAppEvents1_ItemSend(object sender, DXOlItemSendEventArgs e)
{
Outlook.MailItem mailItem = null;
Outlook.Recipients recipients = null;
mailItem = e.Item as Outlook.MailItem;
try
{
// Some code goes here
if (editButtonClicked || swOffline)
{
e.Cancel = true;
if (swOffline)
{
mailItem.Save();
timer.Start();
}
}
}
catch (Exception ex)
{
}
finally
{
}
}
The timer will work fine as long as you keep in the MailItem object referenced. It looks like your mailItem variable is declared on the local level, where it will be garbage collected.