EWS Java-hasAttachments对于内联/嵌入式附件返回false
我正在阅读带有内嵌/嵌入图像的电子邮件,大部分是发件人签名图像。 但是当我试图查找email.hasaAttachments()是否返回false时,如果我检查email.getAttachments()它向我显示内联附件。这是我的代码,我做错什么了吗EWS Java-hasAttachments对于内联/嵌入式附件返回false,java,exchangewebservices,email-attachments,ewsjavaapi,Java,Exchangewebservices,Email Attachments,Ewsjavaapi,我正在阅读带有内嵌/嵌入图像的电子邮件,大部分是发件人签名图像。 但是当我试图查找email.hasaAttachments()是否返回false时,如果我检查email.getAttachments()它向我显示内联附件。这是我的代码,我做错什么了吗 try { Item itm = Item.bind(service, itemId, new PropertySet( BasePropertySet.FirstClassProperties,
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
}
}
试试看{
Item itm=Item.bind(服务、itemId、新属性集(
BasePropertySet.FirstClassProperties,
ItemSchema.Attachments、ItemSchema.HasAttachments、,
ItemSchema.extendedProperties));
emailMessage=emailMessage.bind(服务,itm.getId(),
新属性集(BasePropertySet.FirstClassProperties,
EmailMessageSchema.Attachments,EmailMessageSchema.HasAttachments);
log.info(From:“+emailMessage.getFrom());
log.info(主题:“+emailMessage.getSubject());
log.info(已接收:“+emailMessage.getDateTimeReceived());
//获取电子邮件附件。
附件=getEmailAttachments(emailMessage,属性);
}
//getEmailAttachments()方法。
试一试{
//检查电子邮件是否有附件。
if(emailMessage.getHasAttachments()){//在此处返回false
//获取所有附件
AttachmentCollection attachmentsCol=emailMessage.getAttachments();//将返回附件
log.info(“文件计数:+attachmentsCol.getCount());
//在附件上循环
对于(int i=0;i
HasAttachments是一个计算属性,其值基于其他道具。Outlook可以设置的一个影响此属性是SmartNoAttach属性(您可以在Mapi编辑器中看到此道具的值),它有效地隐藏Outlook中的回形针,其中邮件具有类似内联附件的签名(并且没有真正的附件)。但它也会影响EWS中的此属性值。HasAttachments是一个计算属性,其值基于其他道具。Outlook可以设置的一个影响此属性是SmartNoAttach属性(您可以在Mapi编辑器中看到此道具的值)这有效地隐藏了outlook中的回形针,其中邮件具有类似内联附件的签名(并且没有真正的附件)。但它也会影响EWS中的此属性值。谢谢Glen,我通过添加一个附加检查来解决此问题。如果(emailMessage.getHasAttachments()| | emailMessage.getAttachments().getItems().size()>0){@Jake-很高兴听到这个消息。谢谢Glen,我通过添加一个额外的检查来解决这个问题。如果(emailMessage.getHasAttachments()| | emailMessage.getAttachments().getItems().size()>0){@Jake-很高兴听到这个消息。