Q:

Attaching alias signature with gmail api in google apps script

I am currently creating a PDF and then attaching it to a sendEmail. In the mail I would like to attach a signature. I have managed to attach the signature of my default primary email, but would like to use the signature of an alias I have already created and approved in my account. Could someone please tell me how to get the alias signature and not my own?
I am using the Gmail API for the email and the Google Apps Script API for the rest.
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"
      }]
});

I have seen a workaround, but don't like the reliability.
function getGmailSignature() {
var draft = GmailApp.search("subject:signature label:draft", 0, 1);
return draft[0].getMessages()[0].getBody();
}

A:

You should use the 'get' method to get the settings associated with the given send-as alias:
//Get the alias object
var alias = Gmail.Users.Settings.SendAs.get(aliasId, aliasEmail);
//Get the signature
var signature = alias.signature;

