使用者在 Gmail 帳戶中建立的標籤。
方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
add | Gmail | 將這個標籤新增至指定討論串,並強制重新整理討論串 (Gmail )。 |
add | Gmail | 將這個標籤新增至指定討論串,並強制重新整理討論串。 |
delete | void | 刪除這個標籤。 |
get | String | 取得這個標籤的 ID。 |
get | String | 取得這個標籤的名稱。 |
get | Gmail | 取得標示這個標籤的討論串。 |
get | Gmail | 取得標示這個標籤的討論串範圍。 |
get | Integer | 取得標示這個標籤的未讀討論串數量。 |
remove | Gmail | 從指定執行緒中移除這個標籤,並強制重新整理執行緒。 |
remove | Gmail | 從指定執行緒移除這個標籤,並強制重新整理執行緒。 |
內容詳盡的說明文件
add To Thread(thread)
將這個標籤新增至指定討論串,並強制重新整理討論串 (Gmail
)。
// label the first thread in the inbox with the label MyLabel const label = GmailApp.getUserLabelByName('MyLabel'); const firstThread = GmailApp.getInboxThreads(0, 1)[0]; label.addToThread(firstThread);
參數
名稱 | 類型 | 說明 |
---|---|---|
thread | Gmail | 要加上標籤的討論串。 |
回攻員
Gmail
— 這個標籤用於鏈結。
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/
另請參閱
add To Threads(threads)
將這個標籤新增至指定討論串,並強制重新整理討論串。每個批次最多可為 100 個郵件串新增標籤。
// label the first three threads in the inbox with the label MyLabel const label = GmailApp.getUserLabelByName('MyLabel'); const threads = GmailApp.getInboxThreads(0, 3); label.addToThreads(threads);
參數
名稱 | 類型 | 說明 |
---|---|---|
threads | Gmail | 要加上標籤的執行緒陣列。 |
回攻員
Gmail
— 這個標籤用於鏈結。
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/
另請參閱
delete Label()
刪除這個標籤。
const label = GmailApp.getUserLabelByName('MyLabel'); label.deleteLabel();
擲回
Error
- 如果無法刪除標籤
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/
另請參閱
get Id()
取得這個標籤的 ID。
const label = GmailApp.getUserLabelByName('MyLabel'); console.log(label.getId());
回攻員
String
:標籤的 ID。
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/
get Name()
取得這個標籤的名稱。
const label = GmailApp.getUserLabelByName('MyLabel'); Logger.log(label.getName()); // logs MyLabel
回攻員
String
:標籤名稱。
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/
get Threads()
取得標示這個標籤的討論串。
如果所有執行緒的大小過大,系統無法處理,這類呼叫就會失敗。如果執行緒大小不明,且可能非常大,請使用 get
,並在每次呼叫中指定要擷取的執行緒範圍。
// Log the subject lines of the threads labeled with MyLabel const label = GmailApp.getUserLabelByName('MyLabel'); const threads = label.getThreads(); for (let i = 0; i < threads.length; i++) { Logger.log(threads[i].getFirstMessageSubject()); }
回攻員
Gmail
:標示這個標籤的執行緒陣列。
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/
get Threads(start, max)
取得標示有這個標籤的討論串範圍。
// log the subject lines of up to the first 30 threads with the label MyLabel const label = GmailApp.getUserLabelByName('MyLabel'); const threads = label.getThreads(0, 30); for (let i = 0; i < threads.length; i++) { Logger.log(threads[i].getFirstMessageSubject()); }
參數
名稱 | 類型 | 說明 |
---|---|---|
start | Integer | 起始執行緒的索引。 |
max | Integer | 要傳回的執行緒數量上限。 |
回攻員
Gmail
:標示這個標籤的執行緒陣列。
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/
get Unread Count()
取得標示這個標籤的未讀討論串數量。
// log the number of unread threads labeled with MyLabel const label = GmailApp.getUserLabelByName('MyLabel'); Logger.log(label.getUnreadCount());
回攻員
Integer
- 未讀取已加上標籤的討論串數量。
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/
remove From Thread(thread)
從指定執行緒中移除這個標籤,並強制重新整理執行緒。
// remove the label MyLabel from the first thread in the inbox const label = GmailApp.getUserLabelByName('MyLabel'); const firstThread = GmailApp.getInboxThreads(0, 1)[0]; label.removeFromThread(firstThread);
參數
名稱 | 類型 | 說明 |
---|---|---|
thread | Gmail | 討論串會取消標籤。 |
回攻員
Gmail
— 這個標籤用於鏈結。
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/
另請參閱
remove From Threads(threads)
從指定執行緒中移除這個標籤,並強制重新整理執行緒。每個批次最多可移除 100 個討論串的標籤。
// remove the label MyLabel from the first three threads in the inbox const label = GmailApp.getUserLabelByName('MyLabel'); const threads = GmailApp.getInboxThreads(0, 3); label.removeFromThreads(threads);
參數
名稱 | 類型 | 說明 |
---|---|---|
threads | Gmail | 要取消標籤的討論串陣列。 |
回攻員
Gmail
— 這個標籤用於鏈結。
授權
使用這個方法的指令碼需要透過下列一或多個範圍或相關 REST API 中的適當範圍授權:
-
https://mail.google.com/