嗨,我正在尝试编写一个 chrome 扩展程序,它需要读取电子邮件附件(纯 txt)。我觉得这应该是可能的,因为 gmail 为您提供了下载链接,但它不是直接链接,这是否使它不可能?
我有以下代码来读取远程文件,该文件不适用于 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>
有人知道如何阅读这样的 Gmail 附件吗? 谢谢
最佳答案
Gmail 有一个指向原始电子邮件源的链接(菜单中的“显示原始邮件”)。不确定是否可以通过编程方式读取它,但如果可以,我会尝试解析原始消息源并从那里获取附件(我相信它们是 Base64 编码的)。
关于javascript - 从 Chrome 扩展程序访问 Gmail 附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7047053/