Sending invitation by delegate
Hi, I have delegate access to a mailbox. However when I create a calendar item using the following script,
credentials = Credentials('[email protected]', 'password')
account = Account(primary_smtp_address='[email protected]', credentials=credentials, autodiscover=True, access_type=DELEGATE)
attendees = ['[email protected]']
item = CalendarItem(
account=account,
folder=account.calendar,
start=tz.localize(EWSDateTime(2018, 5, 10, 3, 0)),
end=tz.localize(EWSDateTime(2018, 5, 10, 3, 30)),
subject="Some meeting invitation",
body="Please come to my meeting",
required_attendees=attendees
)
item.save(send_meeting_invitations=SEND_TO_ALL_AND_SAVE_COPY)
and send it, it gets reflected as me as the organiser and not the primary email for which I have delegate access. Any way I can get this done?
You should be able to set the organizer explicitly with organizer='[email protected]'. See also #340
I have access as an editor to the primary email's calendar. However it is not getting reflected as him as the organiser even though I set it explicitly
Let me check with all the rights on the primary's account, not just calendar. But its weird since I am able to do the same thing from within outlook, but not from the python library :/
No luck :(
I think we'll need a working example in e.g. C# or a trace of the XML requests and responses of a working interaction with Exchange to work out what we're doing differently.
I suspect the item.save(send_meeting_invitations=SEND_TO_ALL_AND_SAVE_COPY) is saving it to the user's calendar and not the actual primary's email address. This is mentioned in the C# request for the EWS.
https://msdn.microsoft.com/en-us/library/office/dn641956(v=exchg.150).aspx#bk_createewsma
I tried out sending the invitation with delegate permission using XML template, and it works perfectly fine. For other users who may find this issue, please use the below XML schema,
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<m:CreateItem SendMeetingInvitations="SendToAllAndSaveCopy">
<m:SavedItemFolderId>
<t:DistinguishedFolderId Id="calendar">
<t:Mailbox>
<t:EmailAddress>[email protected]</t:EmailAddress>
</t:Mailbox>
</t:DistinguishedFolderId>
</m:SavedItemFolderId>
<m:Items>
<t:CalendarItem>
<t:Subject>Team building exercise</t:Subject>
<t:Body BodyType="HTML">Lets learn to really work as</t:Body>
<t:ReminderMinutesBeforeStart>60</t:ReminderMinutesBeforeStart>
<t:Start>2018-05-10T23:00:33.756+05:30</t:Start>
<t:End>2018-05-10T23:30:33.756+05:30</t:End>
<t:Location>Conference Room 12</t:Location>
<t:RequiredAttendees>
<t:Attendee>
<t:Mailbox>
<t:EmailAddress>[email protected]</t:EmailAddress>
</t:Mailbox>
</t:Attendee>
</t:RequiredAttendees>
</t:CalendarItem>
</m:Items>
</m:CreateItem>
</soap:Body>
</soap:Envelope>
and this XML should be POST using the credentials of [email protected] for connecting to the exchange services.
I feel the definition of item.save is the one we need to update in exchangelib, since C# documentation mentions,
meeting.Save(new FolderId(WellKnownFolderName.Calendar, "[email protected]"), SendInvitationsMode.SendToAllAndSaveCopy);
Note that when you save the item, the Save method call must identify the mailbox owner's Calendar folder. If the mailbox owner's Calendar folder is not specified, the meeting request gets saved to the delegate's calendar and not the mailbox owner's Calendar folder. You can include the mailbox owner's Calendar folder in the Save method call in two ways. We recommend that you instantiate a new instance of the FolderId object by using the WellKnownFolderName and the SMTP address of the mailbox owner.
meeting.Save(new FolderId(WellKnownFolderName.Calendar, "[email protected]"), SendInvitationsMode.SendToAllAndSaveCopy);
OR
Mailbox primary = new Mailbox("[email protected]"); Folder primaryCalendar = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, primary)); … meeting.Save(primaryCalendar.Id, SendInvitationsMode.SendToAllAndSaveCopy);
Source is here, https://msdn.microsoft.com/en-us/library/office/dn641956(v=exchg.150).aspx
I certainly agree with you that we should be comparing the XML generated from the exchangelib code and this XML to see what is going wrong. Will update you on it once I check :)
Thanks for the updates! I'm reopening the ticket to make sure it doesn't get lost.
Hi @ShaktiKShrivastava
Can you capture the XML that exchangelib produces in the latest version (1.11.4)? I suspect this may have been fixed, but I'd like to be sure, and I don't have a test server with multiple accounts ATM.
Clopsing this issue as outdated. Setting a parent folder as a DistinguishedFolderId with a specific mailbox has been supported for quite a while.