Access Gmail attachment from a chrome extension?

血红的双手。 提交于 2019-12-05 03:46:12

问题


Hi I am trying to write a chrome extension which needs to read in an email attachment (plain txt). I feel this should be possible as gmail gives you a download link, however it is not a direct link does this make it impossible?

I have the following code to read a remote file which works just not for gmail:

<script>
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "http://remote.com/remote_file", true);
txtFile.onreadystatechange = function() {
  if (txtFile.readyState === 4) {  // Makes sure the document is ready to parse.
    if (txtFile.status === 200) {  // Makes sure it's found the file.

        allText = txtFile.responseText; 
        lines = txtFile.responseText.split("\n"); // Will separate each line into an array
        alert(allText)
    }
}
}
txtFile.send(null);
</script>

Does anybody know how I can read a gmail attachment like this? thanks


回答1:


Gmail has a link to original email source ("Show Original" from the menu). Not sure if it is possible to read it programmatically, but if it is, I would try to parse original message source instead and get attachments from there (they are base64 encoded I beleive).



来源:https://stackoverflow.com/questions/7047053/access-gmail-attachment-from-a-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!