google apps script - get message id/unique id of a mail in gmail contextual gadget -


i trying write gmail contextual gadget. ready building blocks (services , gadgets, manifest.repositories...) basic hello world working fine.

to simplify lets say, " i have mark favorite " functionality in widget

i needing store (in sql database) object against marked favorite mails.

and mails open, widget load , want make ajax call database , check if "this particular mail" favorite mail or not.

ques : require unique message id in java-script whenever user marks email favorite. store unique message id in favorite list in database.

the manifest


<?xml version="1.0" encoding="utf-8" ?> <applicationmanifest xmlns="http://schemas.google.com/applicationmanifest/2009">  <!-- support info show in marketplace & control panel --> <support> <!-- url application setup optional redirect during install --> <link rel="setup" href="https://www.google.com" />  <!-- url application configuration, accessed app settings  page in control panel --> <link rel="manage" href="https://www.google.com" />  <!-- url explaining how customers support. --> <link rel="support" href="https://www.google.com" />  <!-- url displayed admins during deletion process,  specify policies such data retention, how claim accounts, etc. --> <link rel="deletion-policy" href="https://www.google.com" /> </support>  <!-- name , description pulled message bundles --> <name>helloworld</name> <description>a simple hello world application testing gmail contextual gadgets</description>  <!-- show link in google's universal navigation users --> <extension id="navlink" type="link"> <name>helloworld</name> <url>http://www.google.com</url> </extension>  <!-- declare our openid realm our app white listed --> <extension id="realm" type="openidrealm"> <url>http://_example.com_</url> </extension>  <!-- extractor -->  <extension id="helloworldextractor" type="contextextractor"> <name>hello world</name> <url>google.com:helloworld</url> <!-- uncomment param apply filter extractor's default output. example regexp below makes match case sensitive. <param name="hello" value="h[a-z]* w[a-z]*"/> --> <triggers ref="helloworldgadget"/> <scope ref="emailsubject"/> <scope ref="emailbody"/> <container name="mail"/> </extension>  <!-- gadget -->  <extension id="helloworldgadget" type="gadget">   <name>hello world gmail contextual gadget</name>   <url>mydomain/widget-module.xml</url>   <container name="mail"/>   <!-- uncomment enable caja. -->   <!-- <param name="caja" value="enabled"/> --> </extension>  <!-- scope -->  <scope id="emailsubject"> <url>tag:google.com,2010:auth/contextual/extractor/subject</url>    <reason>this application searches subject: line of each email   text "hello world."</reason> </scope>  <scope id="emailbody">   <url>tag:google.com,2010:auth/contextual/extractor/body</url>   <reason>this application searches message body of each email   text "hello world."</reason> </scope>  </applicationmanifest> 

the widget

    <?xml version="1.0" encoding="utf-8"?> <module>  <moduleprefs title="hello world"     description="matches , echoes 'hello world' string in emails"     height="20"     author="sarah m , walter q"     author_email="..."     author_location="mountain view, ca">      <!-- declare feature dependencies. -->      <!-- 1 not specific gmail contextual gadgets. -->     <require feature="dynamic-height"/>      <!-- next feature, caja, optional, , supported      use within test domains. uncomment tag      non-production gadgets. -->     <!-- <require feature="caja"/> -->      <!-- next feature, google.contentmatch, required      gmail contextual gadgets.      <param> - specify 1 or more comma-separated extractor ids in      param named "extractors". line overridden extractor id      in manifest, still expected present. -->     <require feature="google.contentmatch">       <param name="extractors">         google.com:helloworld       </param>     </require>    </moduleprefs>    <!-- define content type , display location. settings    "html" , "card" required gmail contextual gadgets. -->   <content type="html" view="card">     <![cdata[       <!-- start single sign-on -->       <script type="text/javascript" src="https://example.com/gadgets/sso.js"></script>       <script type="text/javascript">          <!-- fetch array of content matches. -->         matches = google.contentmatch.getcontentmatches();         var matchlist = document.createelement('ul');         var listitem;         var extractedtext;      //**i want unique message id on here**          <!-- iterate through array , display output each match. -->         (var match in matches) {           (var key in matches[match]) {             listitem = document.createelement('li');             extractedtext = document.createtextnode(key + ": " + matches[match][key]);             listitem.appendchild(extractedtext);             matchlist.appendchild(listitem);           }         }         document.body.appendchild(matchlist);         gadgets.window.adjustheight(100);       </script>     ]]>   </content> </module> 

i need unique message if on here:

//i want unique message id on here

edit ==============================================================================

as suggested have made following changes :

my manifest :

 <?xml version="1.0" encoding="utf-8" ?> <applicationmanifest xmlns="http://schemas.google.com/applicationmanifest/2009">    <!-- support info show in marketplace & control panel -->   <support>     <!-- url application setup optional redirect during install -->     <link rel="setup" href="https://www.google.com" />     <!-- url application configuration, accessed app settings      page in control panel -->     <link rel="manage" href="https://www.google.com" />     <!-- url explaining how customers support. -->     <link rel="support" href="https://www.google.com" />     <!-- url displayed admins during deletion process,      specify policies such data retention, how claim accounts, etc. -->     <link rel="deletion-policy" href="https://www.google.com" />   </support>    <!-- name , description pulled message bundles -->   <name>helloworld</name>   <description>a simple hello world application testing   gmail contextual gadgets</description>    <!-- show link in google's universal navigation users -->   <extension id="navlink" type="link">     <name>helloworld</name>     <url>http://www.google.com</url>   </extension>    <!-- declare our openid realm our app white listed -->   <extension id="realm" type="openidrealm">     <url>http://_example.com_</url>   </extension>    <extension id="uniqueid" type="contextextractor">     <name>custom_extractor_7</name>          <url>sample2foruniquereceipients:custom_extractor_7</url>            <triggers ref="helloworldgadget" />          <scope ref="senderscope" />          <container name="mail" />        </extension>  <!-- extractor  <extension id="from" type="contextextractor">   <name>email sender</name>   <url>google.com:senderemailextractor</url>   <param name="sender_email" value="amalhotra@ivp.in"/>   <triggers ref="helloworldgadget"/>   <scope ref="senderscope"/>   <container name="mail"/> </extension>  <extension id="messageid" type="contextextractor">   <name>message id extractor</name>   <url>google.com:messageidextractor</url>   <param name="message_id" value=".*"/>   <triggers ref="helloworldgadget"/>   <scope ref="messageid"/>   <container name="mail"/> </extension> --> <!-- gadget -->  <extension id="helloworldgadget" type="gadget">   <name>hello world gmail contextual gadget</name>   <url>my_gadget_url</url>   <container name="mail"/>   <!-- uncomment enable caja. -->   <!-- <param name="caja" value="enabled"/> --> </extension>  <!-- scope -->  <scope id="emailsubject">   <url>tag:google.com,2010:auth/contextual/extractor/subject</url>   <reason>this application searches subject: line of each email   text "hello world."</reason> </scope>  <scope id="emailbody">   <url>tag:google.com,2010:auth/contextual/extractor/body</url>   <reason>this application searches message body of each email   text "hello world."</reason> </scope>  <scope id="messageid">   <url>tag:google.com,2010:auth/contextual/extractor/message_id</url>   <reason>this application searches message header of each email   text.</reason> </scope>   <scope id="emailmessageid">   <url>tag:google.com,2010:auth/contextual/extractor/message_id</url>   <reason>this message id , probalbly trigger widget</reason> </scope>   <scope id="senderscope">   <url>tag:google.com,2010:auth/contextual/extractor/from_address</url>   <reason>this application searches subject: line of each email     text "hello world."</reason>     </scope>       </applicationmanifest> 

custom extractor

 <?xml version="1.0" encoding="utf-8"?>       <opencobdata id="custom_extractor_7">        <extractorspec platform="gmail" language="en">         <search>                     <pattern input_fields="from_email">                      <![cdata[(myemailaddress@mydomain.in)]]>                    </pattern>               </search>                 <response platform="gmail" format="cardgadget">                   <output name="id">{@__message_id__}</output>                     <output name="sender">{@__from_address__}</output>                   <output name="date">{@__date_sent__}</output>                    <output name="to">{@__to_address__}</output>                      <!--output name="email_subject">{@__subject__}</output>                  <output name="received_date">{@__date_received__}</output-->                 </response>          </extractorspec>         </opencobdata> 

use message id extractor give frontend unique message id.

extractor detail :

id  = google.com:messageidextractor  description = matches gmail frontend message id of message (this 64-bit hexadecimal value, different rfc 822 message-id)  scope   = tag:google.com,2010:auth/contextual/extractor/message_id  output fields   = @message_id - message id of message 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -