title: How to retrieve gmail signature with google apps script
body: <p>I've created a script in google apps script which reads the contents of a google doc into a draft message in gmail.  It doesn't, however, append the user's signature.</p>
  
  <p>So my plan would be to retrieve the signature, and then append to the contents of the google doc, and then put into a draft message.</p>
  
  <p>I see that there is information for retrieving a users gmail signature here:  <a href="https://developers.google.com/admin-sdk/email-settings/#manage_signature_settings" rel="nofollow">https://developers.google.com/admin-sdk/email-settings/#manage_signature_settings</a>, but I am am having trouble trying to implement it in my existing script.</p>
  
  <p>How should I proceed?  (current script follows)</p>
  
  <pre><code>function doGet() {
  createDraft()
  return HtmlService.createHtmlOutput('&lt;b&gt;Your catering email template can now be found in your &lt;a href="https://mail.google.com/mail/#drafts"&gt;Drafts&lt;/a&gt; folder!&lt;/b&gt;');
  }
  
  function createDraft() {
  
  var forScope = GmailApp.getInboxUnreadCount(); // needed for auth scope
  
  var doc = DocumentApp.openById('1fsRMxtLx3IBEYvmVy9W8uHLw3Uf2OIh4L7ZSxpkixbY');
  
  var body = doc.getBody();
  
  var mbody = body.getText();
  
  
  
  var raw = 
    'Subject: Catering Proposal\r\n' + 
    'Content-Type: multipart/alternative; boundary=1234567890123456789012345678\r\n' + '\r\n' +
    mbody + '\r\n' +
    '--1234567890123456789012345678--\n';
  
  var draftBody = Utilities.base64Encode(raw);
  
  Logger.log(draftBody);
  
  var params = {method:"post",
              contentType: "application/json",
              headers: {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
              muteHttpExceptions:true,
              payload:JSON.stringify({
                "message": {
                  "raw": draftBody
                }
              })
             };
  
  var resp = UrlFetchApp.fetch("https://www.googleapis.com/gmail/v1/users/me/drafts", params);
  Logger.log(resp.getContentText());
  }
  </code></pre>
  
  <p>I greatly appreciate any help that can be provided!</p>