Niels
Niels

Reputation: 426

EWS - Get attachments without body attachments

I wrote a Console Application with EWS to read an mailbox, get all the attachments from the mail (if it has any) and then delete the mail.

Now I have the 'problem' that in my list of attachments there are also items, like the footer image from the body. Is there a way to check if it's a body image for example?

This is my code:

if (mail.HasAttachments) {
     EmailMessage message = EmailMessage.Bind(service, mail.Id, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.TextBody, EmailMessageSchema.Attachments));
     foreach (Attachment Att in message.Attachments) {
            if (Att is FileAttachment) {
               FileAttachment fileAtt = Att as FileAttachment;
               //DO STUFF
            }
     }
}

Thank you

Upvotes: 0

Views: 311

Answers (1)

Niels
Niels

Reputation: 426

SOLUTION: Check if the attachment has attribute 'IsInline' on false.

Upvotes: 1

Related Questions