Outlook电子邮件正文中的消息被覆盖。

huangapple go评论101阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年2月27日 13:33:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/75577039.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定