[英]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.