I am developing an Addin for outlook 2013. It is a sample project and what I want to do is to remove all attachments from mailitem. This is how i do it
while (mail.Attachments.Count > 0)
{
try
{
mail.Attachments.Remove(1);
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}
Edit: I have also tried the way to remove them with an inverted
for loop(for i = mail.Attachments.Count; i > 1; i--) but got same result
And it works fine except for the fact that it throws this exception on console:
Exception thrown: 'System.Runtime.InteropServices.COMException' in PCMailAddIn.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll