Reputation: 1
I'm developing Outlook VSTO add-in that checks Outlook.MailItem attachments. As far as I need to get access to internals of OLE and .msg file (embedded)attachments, I use glue with C++ Extended MAPI.
I received digitally signed message and when I'm trying to reply the save confirmation dialog is showing (with caption - "...If the changes are saved, the message will lose its digital signature.").
This behavior repeats only when I'm trying to make reply for digitally signed message. In the code below add-in call Save() for Outlook.MailItem (saves it into Drafts folder by default
and after that MailItem obtains EntryID), set Cancel=true and make some long work with attachments in another thread and if the work result is ok, add-in call MailItem.Send() programmatically.
Obviously this dialog shows when mailItem.Save() was called. But without mailItem.Save() call, I can't to obtain attachment type (PR_ATTACH_METHOD through GetProps or HrGetOneProp return NO_ATTACHMENT) in C++ part.
private void ApplicationItemSendHandler(object Item, ref bool Cancel)
{
Outlook.MailItem mailItem = null;
bool errorCaused = false;
try
{
mailItem = Item as Outlook.MailItem;
if (mailItem == null)
return;
if (mailItem.Attachments.Count == 0)
{
Marshal.ReleaseComObject(mailItem);
return;
}
if (String.IsNullOrEmpty(mailItem.EntryID))
mailItem.Save();
Cancel = true;
//make some long work with attachments.
}
catch (Exception e)
{
errorCaused = true;
Logger.Debug($"Error occured during call {MethodBase.GetCurrentMethod().Name}: {e.Message}");
}
finally
{
if (errorCaused && mailItem != null) Marshal.ReleaseComObject(mailItem);
}
}
My question - how to suppress or get around this dialog?
Upvotes: 0
Views: 272
Reputation: 66215
You can instead do the processing in the Items.ItemAdd
event on the Sent Items folder - the message will be saved at that point.
Upvotes: 0