use of com.google.api.services.gmail.model.ModifyMessageRequest in project syndesis-qe by syndesisio.
the class GMailUtils method modifyMessage.
/**
* Modify the labels a message is associated with.
*
* @param userId User's email address. The special value "me"
* can be used to indicate the authenticated user.
* @param messageId ID of Message to Modify.
* @param labelsToAdd List of label ids to add.
* @param labelsToRemove List of label ids to remove.
* @throws IOException when something goes wrong
*/
public void modifyMessage(String userId, String messageId, List<String> labelsToAdd, List<String> labelsToRemove) throws IOException {
ModifyMessageRequest mods = new ModifyMessageRequest().setAddLabelIds(labelsToAdd).setRemoveLabelIds(labelsToRemove);
Message message = getClient().users().messages().modify(userId, messageId, mods).execute();
log.info("Message with id: " + message.getId() + "was modified");
log.debug(message.toPrettyString());
}
use of com.google.api.services.gmail.model.ModifyMessageRequest in project teammates by TEAMMATES.
the class EmailAccount method markMessageAsRead.
private static void markMessageAsRead(Gmail service, String username, Message messageStub) throws IOException {
final ModifyMessageRequest modifyMessageRequest = new ModifyMessageRequest().setRemoveLabelIds(Collections.singletonList("UNREAD"));
service.users().messages().modify(username, messageStub.getId(), modifyMessageRequest).execute();
}
Aggregations