我正在构建一个应用,我正在使用Gmail API从Gmail中获取电子邮件.
在电子邮件中,有1个图像直接嵌入电子邮件正文(内联图像不附件).我能够提取text/html部分,并且它在浏览器上正确显示,但是在内嵌图像的情况下,它显示了破碎的图像.
在图片标签中,它显示为
<img src=\"cid:ii_jfi5vwc30_1628627122d12121\" width=\"454\" height=\"255\">
Run Code Online (Sandbox Code Playgroud)
它在src中提供内容id而不是image url .有谁知道我应该如何使用浏览器页面中的cid显示内嵌图像.我该如何从cid获取base64格式的图像?
我想从 gmail 下载 100 多封电子邮件的 pdf 格式。通过 gmail 中的打印选项手动下载所有内容会太长。
此 python 脚本检索所选标签中的电子邮件。我怎样才能把这封电子邮件转换成pdf文件。
# source = https://developers.google.com/gmail/api/quickstart/python?authuser=2
from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
SCOPES = ['https://www.googleapis.com/auth/gmail.readonly']
def main():
creds = None
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request()) …Run Code Online (Sandbox Code Playgroud)