Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hope this will help you. This is an working example which will get the user's HTML signature or Update HTML signature</p> <pre><code>/* ---------------------------------------------------------------------------------- This function will update the HTML signature of a user. Input will be jason data To disable signature, pass an empty string as signature value sample parameter ob = {user='hps', signature='&lt;b&gt;Regards&lt;/b&gt;&lt;br&gt;Waqar'} To disable signature ob = {user='hps', signature=''} ---------------------------------------------------------------------------------- */ function updateSignature(ob) { //ob = {}; //ob.user = "hps"; //ob.signature = "&lt;b&gt;Regards&lt;/b&gt;&lt;br&gt;Waqar"; var base = 'https://apps-apis.google.com/a/feeds/emailsettings/2.0/'; var xmlRaw = '&lt;?xml version="1.0" encoding="utf-8"?&gt;'+ '&lt;atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006"&gt;'+ '&lt;apps:property name="signature" value="'+htmlEncode(ob.signature)+'" /&gt;'+ '&lt;/atom:entry&gt;'; var fetchArgs = googleOAuth_('emailSetting',base); fetchArgs.method = 'PUT'; fetchArgs.payload = xmlRaw; fetchArgs.contentType = 'application/atom+xml'; var domain = UserManager.getDomain(); var url = base+domain+'/'+ob.user+'/signature'; var urlFetch = UrlFetchApp.fetch(url, fetchArgs); var status = urlFetch.getResponseCode(); return status; } //----------------------------------------------------------------------------------------------------------- //This function will retreive Signature settings as json. /*Sample returned object {user=hps, signature=&lt;b&gt;Regards&lt;/b&gt;&lt;br&gt;Waqar} */ //----------------------------------------------------------------------------------------------------------- function retrieveSignature(user) { var user = 'hps'; var base = 'https://apps-apis.google.com/a/feeds/emailsettings/2.0/'; var fetchArgs = googleOAuth_('emailSetting',base); fetchArgs.method = 'GET'; var domain = UserManager.getDomain(); var url = base+domain+'/'+user+'/signature?alt=json'; var urlFetch = UrlFetchApp.fetch(url, fetchArgs); var jsonString = urlFetch.getContentText(); var jsonArray = Utilities.jsonParse(jsonString).entry.apps$property; var ob = {}; ob.user = user; for(var i in jsonArray){ ob[jsonArray[i].name] = jsonArray[i].value; } return ob; } //Google oAuthConfig.. function googleOAuth_(name,scope) { var oAuthConfig = UrlFetchApp.addOAuthService(name); oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope); oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken"); oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); oAuthConfig.setConsumerKey("anonymous"); oAuthConfig.setConsumerSecret("anonymous"); return {oAuthServiceName:name, oAuthUseToken:"always"}; } //This function will escape '&lt;' and '&gt;' characters from a HTML string function htmlEncode(str){ str = str.replace(/&lt;/g,'&amp;lt;'); return str.replace(/&gt;/g,'&amp;gt;') } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload