# Adding a Label to a Message using Message ID for Gmail

Gists

These are sample scripts for adding a label to a message using message ID for Gmail.

## Sample 1

This sample adds a label to a thread using message ID. In this case, all messages in the thread have the label. Even if it adds a label to a message in the thread using addLabel(), all messages in the thread have the label, becauce addLabel can only be used for the thread.

var messageId = "#####";
var label = "samplelabel";


## Sample 2

If you want to give a label to one of messages in the thread, please use this. This sample adds a label to a message using message ID. In this case, only one message of message ID in the thread has the label.

var messageId = "#####";