Search in sources :

Example 1 with ModifyMessageRequest

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());
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) Message(com.google.api.services.gmail.model.Message) ModifyMessageRequest(com.google.api.services.gmail.model.ModifyMessageRequest)

Example 2 with ModifyMessageRequest

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();
}
Also used : ModifyMessageRequest(com.google.api.services.gmail.model.ModifyMessageRequest)

Aggregations

ModifyMessageRequest (com.google.api.services.gmail.model.ModifyMessageRequest)2 Message (com.google.api.services.gmail.model.Message)1 MimeMessage (javax.mail.internet.MimeMessage)1