gpt4 book ai didi

java - 使用 Java 中的 Microsoft Exchange 从收件箱中挑选转发的邮件时出现问题

转载 作者:行者123 更新时间:2023-12-02 08:44:58 25 4
gpt4 key购买 nike

我有一个工作代码,可以连接到 Microsoft Outlook 并根据某些过滤器获取邮件。它可以很好地阅读直邮,但如果转发则无法选择相同的邮件。感谢任何帮助。

    List<SearchFilter> searchFilterCollection = new ArrayList<>();
searchFilterCollection.add(new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived,localDate));

// flag to pick only email which contains attachments
searchFilterCollection.add(new SearchFilter.IsEqualTo(ItemSchema.HasAttachments, Boolean.TRUE));
List<MetaInfoDTO> filterList = channel.getFilters();
// for each channel
log.info("Email from: {}", definedChannelFilter.getFieldData());
EmailAddress manager = new EmailAddress("abcd@outlook.com");
SearchFilter.IsEqualTo fromManagerFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.Sender, manager);
searchFilterCollection.add(fromManagerFilter);
log.info("Email Subject: {}", definedChannelFilter.getFieldData());
searchFilterCollection.add(new SearchFilter.ContainsSubstring(ItemSchema.Subject,"Subject ASDF"));
log.info("Email Body Content: {}", definedChannelFilter.getFieldData());
searchFilterCollection.add(new SearchFilter.ContainsSubstring(ItemSchema.Body,"Body Content if any"));

return new SearchFilter.SearchFilterCollection(LogicalOperator.And, searchFilterCollection);

最佳答案

您必须重新访问代码中的过滤器。

这是我阅读附加电子邮件的代码,我可以打印带有附件的转发电子邮件。

private static void readAttachmentEmail(ExchangeService service) throws Exception {
// Bind to the Inbox.
Folder inbox = Folder.bind(service, WellKnownFolderName.Inbox);
ItemView view = new ItemView(5);
List<SearchFilter> searchFilterCollection = new ArrayList<>();
// flag to pick only email which contains attachments
searchFilterCollection.add(new SearchFilter.IsEqualTo(ItemSchema.HasAttachments, Boolean.TRUE));
// for each channel
EmailAddress manager = new EmailAddress("manager@email.com");
SearchFilter.IsEqualTo fromManagerFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.Sender, manager);
searchFilterCollection.add(fromManagerFilter);
//searchFilterCollection.add(new SearchFilter.ContainsSubstring(ItemSchema.Subject,"Subject ASDF"));
//searchFilterCollection.add(new SearchFilter.ContainsSubstring(ItemSchema.Body,"Body Content if any"));
SearchFilter finalSearchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, searchFilterCollection);
service.findItems(inbox.getId(), finalSearchFilter, view).forEach(item->{
try {
System.out.println("id==========" + item.getId());
System.out.println("sub==========" + item.getSubject());
} catch (ServiceLocalException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
}

关于java - 使用 Java 中的 Microsoft Exchange 从收件箱中挑选转发的邮件时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61142653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com