Search code examples
javaexchangewebservicesewsjavaapi

Java EWS - how to get attachment type


I'm working on EWS java api, I want to know if an attachment is of type

  • ItemAttachment
  • FileAttachment

something like this

 if (attachment is ItemAttachment) // how to in Java api?
 if (attachment is FileAttachment) // how to in Java api?

Solution

  • You can use instanceof:

    if (attachment instanceof ItemAttachment) {
    ...
    }