英文:
Messages in Outlook email body is getting overwritten
问题
我希望脚本检查一个名为suspended_stat的列表是否包含项目,如果有项目,则在Outlook正文中写入一条消息,然后检查另一个名为outlook_stat_final的列表是否包含项目,然后在Outlook正文中写入消息。
问题是只有最后一个邮件正文项(TEXT_2)显示在电子邮件正文中,而似乎suspended_stat的消息被覆盖了。如何确保消息不被覆盖?
if suspended_stat:
mail_item.Body = greet + msg + "\n".join(suspended_stat) + "\t\n \t\n" + "text_1. \t\n \t\n"
else:
mail_item.Body = greet + "未检测到任何活动" + "\t\n \t\n"
if outlook_stat_final:
mail_item.Body = "\n".join(outlook_stat_final) + "\t\n \t\n" + signature
else:
mail_item.Body = "TEXT_2. \t\n\t\n" + signature
英文:
I want the script to check if a list (suspended_stat) has items in it and write a message in the outlook body and then check if another list (outlook_stat_final) has items in it and then write the message in the outlook body.
Problem is only last mailbody.item (TEXT_2) shows up in the email body, and it seems like suspended_stat messages are getting overwritten. How to make sure messages are not overwritten?
if suspended_stat:
mail_item.Body = greet + msg + "\n".join(suspended_stat) + '\t\n \t\n' "text_1. \t\n \t\n"
else:
mail_item.Body = greet + "No activity detected" '\t\n \t\n'
if outlook_stat_final:
mail_item.Body= "\n".join(outlook_stat_final) + "\t\n \t\n" + signature
else:
mail_item.Body = "TEXT_2. \t\n\t\n" + signature
答案1
得分: 0
如果我理解正确,这是因为你在底部覆盖了消息,如果...创建另一个变量用于底部消息或者连接底部消息,例如:mail_item.Body += ...
。
尝试:
if suspended_stat:
mail_item.Body = greet + msg + "\n".join(suspended_stat) + '\t\n\t\n' + "text_1. \t\n\t\n"
else:
mail_item.Body = greet + "No activity detected" + '\t\n\t\n'
if outlook_stat_final:
mail_item.Body += "\n".join(outlook_stat_final) + "\t\n\t\n" + signature
else:
mail_item.Body += "TEXT_2. \t\n\t\n" + signature
英文:
If I understand correctly is because you overwrite the message in the bottom if... create another variable for bottom message or concat the bottom message, like: mail_item.Body += ...
Try:
if suspended_stat:
mail_item.Body = greet + msg + "\n".join(suspended_stat) + '\t\n \t\n' "text_1. \t\n \t\n"
else:
mail_item.Body = greet + "No activity detected" '\t\n \t\n'
if outlook_stat_final:
mail_item.Body += "\n".join(outlook_stat_final) + "\t\n \t\n" + signature
else:
mail_item.Body += "TEXT_2. \t\n\t\n" + signature
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论