How to create Gmail labels with GAS (GoogleAppsScript).
GmailApp.createLabel(label name)
You can create a label by using ‘GmailApp.createLabel(name)’.
GmailApp.createLabel('テストラベル');
Just by executing this, the label name of the argument is newly created.
Create a function that creates labels
Create a function that creates labels.
function CreateNewLabel(){
GmailApp.createLabel('テストラベル');
}
![](https://eguweb.jp/wp-content/uploads/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88-2022-10-08-12.40.31.jpg)
I’ll try it.
![](https://eguweb.jp/wp-content/uploads/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88-2022-10-08-12.40.50-1024x383.jpg)
At the time of execution, as usual, a confirmation screen for granting permission to execute will appear, so proceed.
![](https://eguweb.jp/wp-content/uploads/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88-2022-10-08-12.41.00-1024x664.jpg)
It seems that you need permission to Gmail this time, so give permission.
![](https://eguweb.jp/wp-content/uploads/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88-2022-10-08-12.41.17-972x1024.jpg)
Once I did that, a new label was created!
![](https://eguweb.jp/wp-content/uploads/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88-2022-10-08-12.42.46-1024x541.jpg)
summary
A new label is created by using ” createLabel(label name) “.
By looping the label names, it can be applied to create all at once! I would like to apply it in various ways.
Please refer to it.