使用Apps Script通过谷歌邮箱的别名发送电子邮件需要进行以下步骤:
function sendEmailUsingAlias() {
// Replace [YOUR ALIAS HERE] with the alias email you want to send from.
var alias = "YOUR_ALIAS_HERE";
// Replace [YOUR EMAIL HERE] with your primary email address.
var recipientEmail = "YOUR_EMAIL_HERE";
// Replace [YOUR SUBJECT HERE] with the subject of your email.
var subject = "YOUR_SUBJECT_HERE";
// Replace [YOUR MESSAGE HERE] with the email message you want to send.
var message = "YOUR_MESSAGE_HERE";
// Send the email using the alias.
GmailApp.sendEmail(
recipientEmail,
subject,
message,
{"from": alias}
);
}
请注意,由于Gmail的安全性改进,Google对第三方应用程序的访问设置了更加严格的限制。如果您使用的是新的Google帐户,则可能需要启用两步验证功能,并向应用授权后生成应用特定