当前位置: 首页>>代码示例>>Python>>正文


Python EmailMessage.set_payload方法代码示例

本文整理汇总了Python中email.message.EmailMessage.set_payload方法的典型用法代码示例。如果您正苦于以下问题:Python EmailMessage.set_payload方法的具体用法?Python EmailMessage.set_payload怎么用?Python EmailMessage.set_payload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在email.message.EmailMessage的用法示例。


在下文中一共展示了EmailMessage.set_payload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: convert

# 需要导入模块: from email.message import EmailMessage [as 别名]
# 或者: from email.message.EmailMessage import set_payload [as 别名]
def convert(filename):
    with open(filename, "r") as file:
        raws    = file.read().split("\n")
        subject = raws[0]
        body    = "\n".join(raws[1:])

        email = EmailMessage()
        email.set_payload(body,"utf8")
        email["Subject"] = subject

        return email
开发者ID:Fougere87,项目名称:unsec,代码行数:13,代码来源:text_to_mail.py

示例2: add

# 需要导入模块: from email.message import EmailMessage [as 别名]
# 或者: from email.message.EmailMessage import set_payload [as 别名]
 def add(self, location: str, content_type: str, payload: str, encoding: str = 'quoted-printable') -> None:
     resource = EmailMessage()
     if content_type == 'text/html':
         resource.add_header('Content-Type', 'text/html', charset='utf-8')
     else:
         resource['Content-Type'] = content_type
     if encoding == 'quoted-printable':
         resource['Content-Transfer-Encoding'] = encoding
         resource.set_payload(quopri.encodestring(payload.encode()))
     elif encoding == 'base64':
         resource['Content-Transfer-Encoding'] = encoding
         resource.set_payload(base64.b64encode(payload))
     elif encoding == 'base64-encoded':  # Already base64 encoded
         resource['Content-Transfer-Encoding'] = 'base64'
         resource.set_payload(payload)
     else:
         raise ValueError('invalid encoding')
     resource['Content-Location'] = location
     self._msg.attach(resource)
开发者ID:bosondata,项目名称:prerender,代码行数:21,代码来源:mhtml.py


注:本文中的email.message.EmailMessage.set_payload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。