python - 使用 Python 阅读 Outlook 并写入 Excel
问题描述
我需要阅读来自特定地址的所有电子邮件并将“一些内容”放入 excel
我在阅读电子邮件方面取得了一些成功,但我坚持将这些电子邮件的内容输入到 Excel 中
import win32com.client
import xlsxwriter
import pandas
wb = xlsxwriter.Workbook('Planned_power_outage.xlsx')
ws = wb.add_worksheet()
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI").Folders
folder = outlook(1)
inbox = folder.Folders("Inbox")
messages = inbox.Items
for message in messages:
if (message.SenderEmailAddress) == 'addess here':
sent_date = message.senton.date()
sender = message.Sender
subject = message.Subject
content = message.body
possible_node = subject.split(" ")[1]
print(sender,subject,content)
i expect to see the output as below in a excel file
SENDER SUBJECT CONTENT
alpha this is subject0 blahbalahblahablah
alpha this is subject1 blahbalahblahablah
alpha this is subject2 blahbalahblahablah
解决方案
推荐阅读
- sql - Case 语句非法表达式 SQL
- groovy - groovy jsonbuilder 删除 json 节点
- azure - Azure Front Door 不重定向以指定应用功能
- java - 如何使用 JPA 和 Hibernate 调用 Oracle 存储过程和函数
- jquery - 再次单击相同按钮时更改文本按钮的功能会变回
- laravel - 如何将用户重定向到贝宝以处理来自 Laravel Inertia Js 的付款
- dax - DAX 魔法还是新立方体?
- python - Django DRF 在序列化程序中获取 ForeignKey 值
- javascript - Mongo DB 日期和时间
- r - 使用 EBImage::channel 的错误?