本文整理汇总了Python中mail.Mail.send_attachment方法的典型用法代码示例。如果您正苦于以下问题:Python Mail.send_attachment方法的具体用法?Python Mail.send_attachment怎么用?Python Mail.send_attachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mail.Mail
的用法示例。
在下文中一共展示了Mail.send_attachment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send_attachment [as 别名]
def main(args):
"""["attachment_mail.py", "[email protected]", "1.txt", "this is a test args"]"""
param_count = len(args)
filename = ''
content = ''
if param_count == 1:
print 'do not have email params'
return
if param_count == 2:
print 'do not have attachments params'
return
if param_count >= 3:
"""file path"""
filename = args[2]
if not os.path.exists(filename):
print 'dattachments not exist'
return
if param_count == 4:
content = args[3]
to_mail_list = args[1].split(',')
mail = Mail()
mail.set_to_list(to_mail_list)
mail.set_subject("详情")
mail.send_attachment(content, filename)