如何使用java ews api将电子邮件标记为已读

时间:2018-05-03 08:36:54

标签: java api outlook exchangewebservices

我正在使用java ews API将电子邮件更新为已读。但是,无法找到更新邮件的正确方法。

1 个答案:

答案 0 :(得分:2)

使用EWS Java API:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
ExchangeCredentials credentials = new WebCredentials("USERNAME", "PASSWORD");       
try {
    service.setCredentials(credentials);
    service.setUrl(new URI("URL"));
    ItemId id = new ItemId("ITEM ID");
    new Item(service);
    Item item = Item.bind(service, id);
    EmailMessage email = (EmailMessage) item;
    if (ewsModel.getMarkEmailAsRead().booleanValue()) {
        email.setIsRead(true);
        email.update(ConflictResolutionMode.AlwaysOverwrite);           
    }}