从 Chrome 扩展程序访问 Gmail 附件?

发布于 2024-11-29 03:29:49 字数 700 浏览 0 评论 0原文

您好,我正在尝试编写一个 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 附件? 谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绿萝 2024-12-06 03:29:49

Gmail 有一个指向原始电子邮件源的链接(菜单中的“显示原始”)。不确定是否可以通过编程方式读取它,但如果可以,我会尝试解析原始消息源并从那里获取附件(我相信它们是 Base64 编码的)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文