return result;
}
@Override
public GmailAttachment getAttachment(int partIndex) {
GmailAttachment result = null;
try {
Object content = this.source.getContent();
if (content instanceof Multipart) {
Multipart multipart = (Multipart)content;
Part bodyPart = multipart.getBodyPart(partIndex);
if (bodyPart.getDisposition() != null) {
if (bodyPart.getDisposition().equalsIgnoreCase(Part.ATTACHMENT)) {
result = new GmailAttachment(partIndex, bodyPart.getFileName(), bodyPart.getContentType(), bodyPart.getInputStream());
}
}
}
else {
throw new GmailException("Failed to get attachement with partIndex :" + partIndex);