Get headers message

402 views
Skip to first unread message

Vasya Pupkin

unread,
Mar 7, 2016, 7:50:37 PM3/7/16
to InboxSDK
Hello!

I need a get header (need "Received: by IP").


My app.js:

1. Inject script and save to localStorage GLOBAL[9] value. GLOBAL[9] - need for URL link original message.

var script = document.createElement('script');
script.textContent = 'localStorage.ik = GLOBALS[9]';
(document.head || document.documentElement).appendChild(script);
script.parentNode.removeChild(script);

2. Generate URL link to original message and GET XHR query.

InboxSDK.load('1.0', 'sdk_...').then(function(sdk) {

sdk.Toolbars.registerToolbarButtonForThreadView({
title: 'Get Email Headers',
section: sdk.Toolbars.SectionNames.INBOX_STATE,
iconUrl: iconUrl,
onClick: function() {

var originalMessageUrl = 'https://mail.google.com/mail/?ui=2&ik=' + localStorage.ik + '&view=om&th=' + window.location.hash.substr(7);

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var originalMessage = xhr.responseText;
headersMessage = originalMessage.split('Content-Type:')[0];
console.log(headersMessage);
}
}
xhr.open('GET', originalMessageUrl, true);
xhr.send();
});

});

Working.

But you can make the method InboxSDK?

Aleem Mawani

unread,
Mar 7, 2016, 7:58:06 PM3/7/16
to Vasya Pupkin, InboxSDK
Have you tried using the Gmail API to get metadata about specific messages. The InboxSDK is trying to avoid functionality that you can easily get from the API. I believe they even have a JS client library and an easy way for chrome extensions to do the oauth authentication so you don't need your own server if you're only going to be making calls during the active user session. 

--
You received this message because you are subscribed to the Google Groups "InboxSDK" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inboxsdk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inboxsdk/d62b1c47-c8ad-40db-9da0-4320a6b7ea66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vasya Pupkin

unread,
Mar 7, 2016, 8:08:25 PM3/7/16
to InboxSDK, entu...@gmail.com
Yes, thanks!

Exists threads.get(format=METADATA) - that's what I need.
Reply all
Reply to author
Forward
0 new messages