如何使用 exchangelib 将电子邮件添加到现有日历条目?
How can I add an email to an existing calendar entry using exchangelib?
我已经安排了一个现有的日历活动。
我正在尝试向该现有事件添加一些电子邮件,但是当我 运行 此功能时它会添加一个新事件。
我需要能够:找到活动,将指定的电子邮件添加到活动,添加电子邮件获得邀请。
(我是 python 的新手,所以尽量不要苛刻判断)
def updateInvite(pEmail,pSubj,iY, iM, iD, iHH, iMM):
pytz_tz = pytz.timezone('America/New_York')
tz = EWSTimeZone.localzone()
items = account.calendar.view(
start=tz.localize(EWSDateTime(iY, iM, iD, iHH, iMM)),
end=tz.localize(EWSDateTime(iY, iM, iD, iHH + 2, iMM)),
)`
for item in items:
sEventSubj = item.subject
item.save(update_fields=['required_attendees'])
被调用
pEmail = 'name.last@company.com'
sSubj = 'Invite Test Meeting with Teams link'
iY = 2020
iD = 29
iM = 4
iHH = 16
iMM = 30
updateInvite(pEmail, sSubj, iY, iM, iD, iHH, iMM)
为此,请使用项目附件。找到您要附加到日历项目的消息并为其创建项目附件:
from exchangelib import ItemAttachment
# Create some filter to get the emails you want to attach
messages = account.inbox.all()[:5]
# Create a filter go get your calendar item
item = account.calendar.get(subject='Hello Python')
for message in messages:
# Create the attachment and give it a name
attachment = ItemAttachment(name='msg %s' % msg.id[:8], item=message)
item.attach(attachment)
我已经安排了一个现有的日历活动。
我正在尝试向该现有事件添加一些电子邮件,但是当我 运行 此功能时它会添加一个新事件。
我需要能够:找到活动,将指定的电子邮件添加到活动,添加电子邮件获得邀请。
(我是 python 的新手,所以尽量不要苛刻判断)
def updateInvite(pEmail,pSubj,iY, iM, iD, iHH, iMM):
pytz_tz = pytz.timezone('America/New_York')
tz = EWSTimeZone.localzone()
items = account.calendar.view(
start=tz.localize(EWSDateTime(iY, iM, iD, iHH, iMM)),
end=tz.localize(EWSDateTime(iY, iM, iD, iHH + 2, iMM)),
)`
for item in items:
sEventSubj = item.subject
item.save(update_fields=['required_attendees'])
被调用
pEmail = 'name.last@company.com'
sSubj = 'Invite Test Meeting with Teams link'
iY = 2020
iD = 29
iM = 4
iHH = 16
iMM = 30
updateInvite(pEmail, sSubj, iY, iM, iD, iHH, iMM)
为此,请使用项目附件。找到您要附加到日历项目的消息并为其创建项目附件:
from exchangelib import ItemAttachment
# Create some filter to get the emails you want to attach
messages = account.inbox.all()[:5]
# Create a filter go get your calendar item
item = account.calendar.get(subject='Hello Python')
for message in messages:
# Create the attachment and give it a name
attachment = ItemAttachment(name='msg %s' % msg.id[:8], item=message)
item.attach(attachment)