Arvind26
Arvind26

Reputation: 135

How to mark email as read using java ews api

I am using java ews API to update the email as read. However didn't able to find right method to update mail.

Upvotes: 2

Views: 2300

Answers (1)

Arvind26
Arvind26

Reputation: 135

Using 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);           
    }}

Upvotes: 4

Related Questions