我正在编写一个
Java应用程序来使用Exchange Web服务下载电子邮件.我正在使用Microsoft的ewsjava API来执行此操作.
我可以获取电子邮件标题.但是,我无法使用此API下载电子邮件附件.以下是代码段.
FolderId folderId = new FolderId(WellKnownFolderName.InBox,"mailBox@example.com"); findResults = service.findItems(folderId,view); for(Item item : findResults.getItems()) { if (item.getHasAttachments()) { AttachmentCollection attachmentsCol = item.getAttachments(); System.out.println(attachmentsCol.getCount()); // This is printing zero all the time. My message has one attachment. for (int i = 0; i < attachmentsCol.getCount(); i++) { FileAttachment attachment = (FileAttachment)attachmentsCol.getPropertyAtIndex(i); String name = attachment.getFileName(); int size = attachment.getContent().length; } } }
item.getHasAttachments()返回true,但attachmentsCol.getCount()为0.