Reputation: 949
I have used Gmail API for reading Mails and it's working fine. I was successfully able to do that. But as I want that particular email as "Mark as Read" (Note: "Mark as Read" not apply the label here) whenever I read that email through Gmail API, I was unable to do so. Actually, I didn't find any method to do so through Gmail API. Is there any way to do so?
PS: I'm using PHP for this process.
Upvotes: 4
Views: 2729
Reputation: 112917
You have to modify the message, and remove the UNREAD
label.
POST https://www.googleapis.com/gmail/v1/users/me/messages/{MESSAGE_ID}/modify?access_token={ACCESS_TOKEN}
{
"removeLabelIds": [
"UNREAD"
]
}
Using the Gmail API PHP client you could do something like the following:
$mods = new Google_Service_Gmail_ModifyMessageRequest();
$mods->setRemoveLabelIds(array("UNREAD"));
$message = $service->users_messages->modify($userId, $messageId, $mods);
Upvotes: 7