How can I get the sizes of the attachments of a mail message? The following code throws an exception: System.ObjectDisposedException: Cannot access a closed Stream
public string GetPropertiesAttachmentSizes(int i)
string attachmentSizes = null;
int counter = 0;
foreach (var attachment in CurrentMessage.Attachments)
if (attachment.ContentType.MediaType.Equals(“message/rfc822”) == false)
// System.ObjectDisposedException: Cannot access a closed Stream.
attachmentSizes[counter++] = attachment.ContentStream.Length.ToString();
How can I avoid this exception?