【问题标题】:Attaching alias signature with gmail api in google apps script在谷歌应用脚​​本中使用 gmail api 附加别名签名
【发布时间】:2023-03-03 11:00:01
【问题描述】:

我目前正在创建 PDF,然后将其附加到 sendEmail。在邮件中,我想附上签名。我设法附上了我的默认主电子邮件的签名,但想使用我已经在我的帐户中创建和批准的别名的签名。有人可以告诉我如何获取别名签名而不是我自己的吗?

我使用 Gmail API 处理电子邮件,使用 Google Apps Script API 处理其余部分。

var signature = Gmail.Users.Settings.SendAs.list("me").sendAs.filter(function(account){if(account.isDefault){return true}})[0].signature;
var body = "Hallo " + vorname + ", <br />hier ist deine vorausgefüllte Nutzungsbedingung. Bitte bringe diese bei deinem ersten Besuch unterschrieben mit.<br />" + signature
GmailApp.sendEmail(email, subject, '', {
bcc: bcc,
htmlBody: body,
from: alias,
name: "DIE HALLE Nutzungsbedingungen",
attachments: [{
        fileName: "DIE HALLE - Nutzungsbedingung_" + nachname + "_" + vorname + "_" + dateString + ".pdf",
        content: response.getBytes(),
        mimeType: "application/pdf"
      }]
});

我看到了一种解决方法,但不喜欢可靠性。

function getGmailSignature() {
var draft = GmailApp.search("subject:signature label:draft", 0, 1);
return draft[0].getMessages()[0].getBody();
}

【问题讨论】:

    标签: google-apps-script gmail-api


    【解决方案1】:

    您应该使用 'get' 方法来获取与给定的发送别名关联的设置:

    //Get the alias object
    var alias = Gmail.Users.Settings.SendAs.get(aliasId, aliasEmail);
    //Get the signature
    var signature = alias.signature;
    

    【讨论】:

      猜你喜欢
      • 2017-02-05
      • 1970-01-01
      • 2022-09-23
      • 2018-06-19
      • 2018-07-30
      • 2020-03-09
      • 2015-05-19
      • 2015-05-17
      • 1970-01-01
      相关资源
      最近更新 更多