0
votes

I’m facing an issue with handling attachments. The scenario is given below,

  1. I’ve an email (mail A) which has an attachment, the attached email (mail B) have 1 more attachments (some file types like pdf, doc, xls etc)
  2. In outlook I open the attached email (mail B) and in outlook ribbon I’ve an action button.
  3. When I click on the action button I’m checking if the attachment is embedded attachment then I’m removing it from the mail body and saving it to local disk. Ex. I’ve tried both

safeMailCopy.Attachments.Item(i).Delete();

and,

safeMailCopy.Attachments.Remove(i);

.. ..

safeMailCopy.SaveAs(Path.Combine(Settings.Instance.DocumentToAddDirectoryFullName,
messageFileName));

but when I open the locally saved copy then I can see the attachments still there in the mail, it’s not getting removed.

But if I’ve a regular email with attachments then I can remove the attachments and save it locally without any issue.

1

1 Answers

0
votes

The problem is Outlook cannot see changes made through MAPI until the item is completely dereferenced and reopened by Outlook. Since removing attachments is not blocked, you can delete the attachment using the original Outlook object assigned to the SafeMailItem.Item property.