我的代碼現在看起來像這樣:
GmailApp.sendEmail(address, subject, body, {htmlBody : body});
我的參考問題:

- 通過編輯 appscript.json 清單檔案將組態檔范圍添加到您的專案。
{
...
"oauthScopes": [
"https://www.googleapis.com/auth/userinfo.profile"
],
...
}
- 添加一個函式,該函式將從 People API 檢索當前用戶的個人資料名稱資訊。
//This will contain a user's names
function getCurrentUser(){
var currentuser = People.People.get("people/me", {"personFields":"names"})
return currentuser.names[0]
}
var firstname = getCurrentUser().givenName //gets the user's first name
var fullname = getCurrentUser().displayName // gets the user's full profile name
//You can then add either variable as the name
GmailApp.sendEmail(address, subject, body, {htmlBody : body signature,cc: "[email protected]",name:firstname});
如果您需要它,您不僅可以檢索名稱,還可以檢索其他用戶個人資料資訊。在此處查看檔案。
uj5u.com熱心網友回復:
采用
const name = 'Alex from Ban' // replace the string by someway to assign the value that you want to use.
GmailApp.sendEmail(address, subject, body, {htmlBody : body, name: name });
參考
- https://developers.google.com/apps-script/reference/gmail/gmail-app#sendemailrecipient,-subject,-body,-options
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/442355.html
