简体   繁体   English

如何使用 python 自定义 gmail 主题

[英]How to customize gmail subject by using python

I want to style gmail subject header while sending email using python.我想在使用 Z23EEEB4347BDD26BDD5Z6B7EE9A3B7 发送 email 时设置 gmail 主题 header 的样式。 I am using python email.mime.text .我正在使用 python email.mime.text There are quite many solutions that covers for styling the message body by using mime.MultiPart but I cannot find for styling the subject.有很多解决方案涵盖了使用mime.MultiPart设置消息正文的样式,但我找不到主题样式。 In below code, I want to style for the subject.在下面的代码中,我想为主题设置样式。

        message = MIMEText(msg_body)
        message['To'] = to 
        message['From'] = sender  
        message['Subject'] = subject

        message = {'message': {'raw': base64.urlsafe_b64encode(message.as_string().encode()).decode(),
                               'threadId': threadId}}

Any idea, how to do it?任何想法,怎么做?

No, you cannot style an email subject.不,您不能设置 email 主题的样式。

An email subject is a plain text string, defined by RFC-2822 as a text field . email 主题是纯文本字符串,由 RFC-2822 定义为文本字段 Any markup you might add to it will be rendered as is, not interpreted.您可能添加到它的任何标记都将按原样呈现,而不是解释。

Email body is a different thing, in a MIME-formatted email it may come in multiple formats, including text/html , which would be rendered as HTML by a client that knows how to do so (eg Gmail). Email正文是另一回事,在 MIME 格式的 email 中,它可能有多种格式,包括text/html ,它将被呈现为 HTML 的客户端知道该怎么做(例如 Gmail)。

If you want to embellish your email's subject, add emoji characters or other Unicode characters:如果您想修饰电子邮件的主题,请添加表情符号或其他 Unicode 字符:

Happy New Year! ❄❄❄

These are going to be rendered by Unicode-capable clients (again, such as Gmail).这些将由支持 Unicode 的客户端(同样,例如 Gmail)呈现。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 python ZDB974238714CA8DE634A7CE1D0F 打印 GMail email 的主题和正文? - How can I print the subject and body of a GMail email using the python API? 适用于Gmail /主题的python电子邮件模块 - python email module for Gmail / subject Python:如何从 gmail API 获取电子邮件的主题 - Python: how to get the subject of an email from gmail API 如何从python中的gmail下载特定主题和日期的电子邮件附件 - how to download an email attachment from gmail in python for a particular subject and date 使用 imaplib 的邮件主题中没有国家字符,Python 中的 email 以读取 gmail 收件箱 - No national characters in mail subject using imaplib, email in Python to read gmail inbox Python Selenium —如何支持Gmail在一个带有自定义主题和正文内容(Gmail)的标签下撰写多个新邮件 - Python Selenium — how to support Gmail compose multiple New message under one Tab with customized subject and body content (Gmail) 如何列出GMail中的所有电子邮件主题? - how to list all the email subject in GMail? 如何在通过gmail发送的电子邮件中添加主题? - How to add a subject to an email being sent with gmail? Django Allauth:如何自定义确认 email 主题? - Django Allauth: How to customize confirmation email subject? Python和GMail-将来自具有指定主题的指定帐户的电子邮件标记为已读 - Python and GMail - Mark email from specified account with defined subject as read
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM