Is there a script to update user signatures in Gsuite?

321 views
Skip to first unread message

Nerio Villalobos

unread,
Dec 4, 2019, 7:30:26 PM12/4/19
to Google Apps Script Community
Hi,

Is there any google script command that allows me to update the signature of all users in my organization based on a template made in HTML?

Regards,

Nervill.

Kim Nilsson

unread,
Jan 12, 2020, 7:25:34 PM1/12/20
to Google Apps Script Community
Hi, Nervill!

I don't have a solution for you with Google Apps Script, but if you're willing to invest a short time to install the very popular python tool GAMADV-XTD3, I did put together a guide for automatically managing signatures with it.

The guide is available here, https://goo.gl/DXmmsB , called fittingly "How to set nicely formatted signatures on staff users currently without signatures". :-)

Riël Notermans

unread,
Jan 13, 2020, 2:53:48 AM1/13/20
to Google Apps Script Community
Yes,

You can use the GMAIL API and urlFetchApp to do this quite easily.
This should get you going. Set the proper scope in your appsscript manifest: "https://www.googleapis.com/auth/gmail.settings.basic"

payload = {}
payload.resource = {signature:"YOURHTML"};

function setSignature(user, payload) {
  var url = "https://www.googleapis.com/gmail/v1/users/"+user+"/settings/sendAs/"+user
  var method = 'PUT';
 
  USER_EMAIL = user;
 

  var bearer = ScriptApp.getOAuthToken();
 
  var params = {
    method: method,
    contentType: "application/json",
    headers:
    {
      Authorization: "Bearer " + bearer
    },
    muteHttpExceptions: true
  }
  if (payload)
  {
    params.payload = JSON.stringify(payload);
  }
 
 
  var response = UrlFetchApp.fetch(url, params).getContentText();
 
  var data = JSON.parse(response);
  return data;
 
}

Met vriendelijke groet,

pic
Riël Notermans
Technisch Directeur
logo
phone
email
email
040 711 41 94
ri...@zzapps.nl
www.zzapps.nl


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/06869dd0-a7cb-4c09-b695-2b82bf5bbc90%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages