0
인라인/임베디드 이미지가 포함 된 이메일을 주로 읽습니다. 주로 보낸 사람 서명 이미지입니다. 하지만 email.hasAttachments()가 false를 반환하는지 확인하려고 할 때 검사 할 경우 email.getAttachments(); 그것은 인라인 첨부 파일을 보여줍니다. 여기에 내 코드가 있는데, 나는 잘못된 것을하고있다.EWS Java - hasAttachments가 인라인/임베디드 첨부 파일에 대해 false를 반환합니다.
try {
Item itm = Item.bind(service, itemId, new PropertySet(
BasePropertySet.FirstClassProperties,
ItemSchema.Attachments,ItemSchema.HasAttachments,
ItemSchema.extendedProperties));
emailMessage = EmailMessage.bind(service, itm.getId(),
new PropertySet(BasePropertySet.FirstClassProperties,
EmailMessageSchema.Attachments, EmailMessageSchema.HasAttachments));
log.info(From: " + emailMessage.getFrom());
log.info(Subject: " + emailMessage.getSubject());
log.info(Received: " + emailMessage.getDateTimeReceived());
//get email attachments.
attachments = getEmailAttachments(emailMessage, properties);
}
//getEmailAttachments() method.
try {
//check if the email has attachments.
if (emailMessage.getHasAttachments()) { //returns false here
//get all the attachments
AttachmentCollection attachmentsCol = emailMessage.getAttachments();// will return the attachments
log.info("File Count: " +attachmentsCol.getCount());
//loop over the attachments
for (int i = 0; i < attachmentsCol.getCount(); i++) {
Attachment attchment = attachmentsCol.getPropertyAtIndex(i);
if (attchment.getIsInline()) {
log.info("There is an inline attachment.");
}
//FileAttachment - Represents a file that is attached to an email item
if (attchment instanceof FileAttachment) {
//my code here
} else if (attchment instanceof ItemAttachment) { //ItemAttachment - Represents an Exchange item that is attached to another Exchange item.
//my code here
}
}
고마워 글렌, 추가 체크를 추가하여 문제를 해결했습니다. if (emailMessage.getHasAttachments() || emailMessage.getAttachments(). getItems(). size()> 0) { – Lucky
@ 완벽하게이 기능이 저에게 도움이되었습니다! 감사합니다 – Jake
@ 제이크 - 듣기 좋게. – Lucky