-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcode.gs
40 lines (30 loc) · 1.12 KB
/
code.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var organization="Your organizations name";
var domainName="YourDomain.org";
function doGet(){
return showAuthWindow();
}
function authScript(){
return true;
}
function test(){
setSignature("[email protected]")
}
function setSignature(userEmail){
var userName=userEmail.split("@")[0]
// Creating Signature String for user
var newUserSignatureString="First Name"+" " +"Last Name"+"<br>"
+organization+"<br>"+"Email"+"<br>";
var xml = '<?xml version="1.0" encoding="utf-8"?>' +
'<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006" >' +
'<apps:property name="signature" value="'+ newUserSignatureString+'" /></atom:entry>';
var base="https://apps-apis.google.com/a/feeds/emailsettings/2.0/";
var url = base + domainName + '/' + userName + '/signature';
var options = {
"method":"PUT",
"headers": {"authorization": "Bearer " + getAdminService().getAccessToken()},
"payload":xml,
"contentType":"application/atom+xml"
}
var results = UrlFetchApp.fetch(url, options);
Logger.log(results)
}