【发布时间】:2017-08-09 17:13:17
【问题描述】:
在 smtplib 发送空白正文时遇到问题,即使该值将很好地打印到控制台。
父方法:
recipient = 'dummied@dummied.com'
text = 'Subject: Employee Departure Notification.\n%s has left Redcated. Their termination is effective %s.' % (employee_name, text)
print('SMTP text: ', text)
message = smtpObj.sendmail(config['Email']['username'], recipient, text)
这部分代码可以正常工作:
if
i['request_variables'][4]['value'] == 'Immediately':
text = 'their termination is effective immediately'
但不适用于以下内容,尽管它将正确的逻辑打印到控制台(空白正文但电子邮件发送其他方式)
last_day_long = datetime.strptime(last_day, '%Y-%m-%d') + timedelta(hours=17)
last_day = str(last_day_long)
text = 'their termination is effective %s at 5:00pm' % last_day
print('Last day value before email: ', last_day)
请忽略我糟糕的代码和格式,提前感谢任何帮助!
【问题讨论】: