admin管理员组文章数量:1394990
I am building an extension for Chrome browser. I wish to be able to parse the content of (the currently viewed) email message in Gmail (and some other email clients, such as Hotmail, Yahoo, etc.). I browsed through Stackoverflow and Google's developer guide, but I could not find how it should be done.
If one could provide a small toy example of how to read the the content of the email (i.e. having a variable which holds the email text\HTML content) it would be great.
thanks.
I am building an extension for Chrome browser. I wish to be able to parse the content of (the currently viewed) email message in Gmail (and some other email clients, such as Hotmail, Yahoo, etc.). I browsed through Stackoverflow and Google's developer guide, but I could not find how it should be done.
If one could provide a small toy example of how to read the the content of the email (i.e. having a variable which holds the email text\HTML content) it would be great.
thanks.
Share Improve this question asked Mar 7, 2012 at 8:40 Mr.Mr. 10.2k14 gold badges67 silver badges91 bronze badges4 Answers
Reset to default 6You should check out the APIs here, https://github./joscha/gmailr, it should get you started.
Edit: There's another newly released unofficial API (still updated) at https://github./KartikTalwar/gmail.js
Have a look at Content Scripts... By using the standard Document Object Model (DOM), they can read details of the web pages the browser visits
Each email has its own message Id which is unique.
Use content.js
to fetch the "messageId" from the elements and then pass it to Gmail API
to fetch the email data.
Sample:
<div class="adn ads" style="display:" data-message-id="189******56e***3" data-legacy-message-id="189******56e***3">
The API returns the data of the email in various format. One of those is the "raw" format which returns the full email body as a base64url encoded string. Send this data as it is to your server and then decrypt the email and save it to your database.
Please refer the similar question: "Get gmail message body of an open mail with a chrome extension"
Better way which I think is to get ids as per your requirement and use GMail APIs to access other details. For example, I've a requirement of all reciepients of the current open thread so accessing the id of the thread and using Gmail APIs. You can get the thread id by using the following code.
var currentThreadId = document.querySelector("[data-inboxsdk-currentthreadid]").getAttribute('data-inboxsdk-currentthreadid');
var legacyThreadId = document.querySelector("[data-thread-perm-id='"+currentThreadId+"']").getAttribute('data-legacy-thread-id');
legacyThreadId will work for APIs.
本文标签: javascriptChrome ExtensionParse Gmail messageStack Overflow
版权声明:本文标题:javascript - Chrome Extension - Parse Gmail message - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744109328a2591215.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论