I have an existing calendar event already scheduled.
I am trying to add a number of emails to that existing event, but when I run this function it adds a new event.
I need to be able to: find the event, add the specified email to the event, have the email added get the invitation.
(I'm new to python so try not to judge harshly)
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'])
Is called with
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)
To do this, use an item attachment. Find the message you would like to attach to your calendar item and create an item attachment for it:
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.