将Outlook电子邮件主体提取到CSV中

发布于 2025-01-28 02:24:07 字数 647 浏览 2 评论 0原文

您好,我每天收到此电子邮件,并试图自动执行此任务。

这是电子邮件主体的一个示例,我不确定其格式是什么。

电子邮件主体:

“

我的目标是将所有行放入CSV文件中。然后,我可以将文本分开,但我不确定如何将其变成CSV。

import win32com.client
import pandas as pd
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6).Folders.Item("Automation")
Mail_Messages = inbox.Items
message = messages.GetLast()
body_content = mail.Body
print(body_content) 

这也是我要获得的当前输出。可以忽略外部电子邮件警告吗?

“当前输出”

Hello I receive this email daily and trying to automate this task.

Here is an example of the email body, I'm not sure what's the format of it.

Email body:

Email Body.

My goal here is to get all the rows into a CSV file. Then I can split the text but I'm not sure how to turn it into a CSV.

import win32com.client
import pandas as pd
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6).Folders.Item("Automation")
Mail_Messages = inbox.Items
message = messages.GetLast()
body_content = mail.Body
print(body_content) 

Also here is the current output I'm getting. Would it be possible to ignore the External Email warning?

Current Output

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木槿暧夏七纪年 2025-02-04 02:24:07

您可以使用字符串函数获取chrexternaltag子字符串之后开始的子字符串。例如,在Python中,您可以使用 split 函数。

You can use string functions to get a substring which starts after the chrexternaltag substring. For example, in Python you could use the Split function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文