python 收取邮件 exchange_Python获取微软Microsoft Exchange邮件信息

本文档展示了如何使用exchangelib Python库连接到Microsoft Exchange邮箱,并获取指定日期范围内的邮件列表。此外,还演示了根据主题和发送者筛选邮件,以及下载邮件内容和附件的方法。
摘要由CSDN通过智能技术生成

importdatetimefrom exchangelib import(

Credentials,

Account,

DELEGATE,

Configuration,

FileAttachment,

EWSDateTime,

EWSTimeZone,

)from exchangelib.protocol importCachingProtocolclassEmailLoader:def __init__(self, username, password):

self.username=username

self.password=password

self.account=self.connect_to_mailbox()defconnect_to_mailbox(self):

cred=Credentials(self.username, self.password)

config= Configuration(server="outlook.office365.com", credentials=cred,)

account=Account(

primary_smtp_address=self.username,

config=config,

autodiscover=False,

access_type=DELEGATE,

)print("--------Connected--------")returnaccountdef get_email_list(self, send_time_gte, subject_like=None, sender=None):""":param send

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值