如何使用SES随附的CSV将数据框和sendmail上的CSV转换为CSV
我必须使用包含数据框的CSV在代码末尾发送MENDMAIL。
我使用BOTO3在AWS Lambda上进行此操作,以打电话给SES。
def sendMail1(value, df):
subject = "Comission"
client = boto3.client("ses")
body = f"""
Comission value is {value}.
"""
message = {"Subject": {"Data": subject}, "Body": {"Html": {"Data": body}}}
attachment = df.to_csv(f"Comission.csv", index=False)
response = client.send_email(Source = "[email protected]", Destination = {"ToAddresses": ["[email protected]"]}, Message = message, Attachment = attachment)
我没有IDEIA如何做,我尝试了DF.TO_CSV方法,并将其包含在附件。没有工作。
其余的代码无需附件零件工作,但是我需要将DF附加到电子邮件。
你们知道该怎么做吗?
I have to sendmail at the end of my code with csv attached containing a dataframe.
Im doing it at AWS Lambda using boto3 to call SES as it follows.
def sendMail1(value, df):
subject = "Comission"
client = boto3.client("ses")
body = f"""
Comission value is {value}.
"""
message = {"Subject": {"Data": subject}, "Body": {"Html": {"Data": body}}}
attachment = df.to_csv(f"Comission.csv", index=False)
response = client.send_email(Source = "[email protected]", Destination = {"ToAddresses": ["[email protected]"]}, Message = message, Attachment = attachment)
I had no ideia how to do it, I tried df.to_csv method and include it as attachment. Did not work.
The rest of the code works without the attachment parts, but I need to attach my df to the e-mail.
Do you guys have any idea how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)