Reputation: 1560
I'm trying to move an email from a delegate inbox to a delegate folder using EWS.
First, I grab all the folders within the delegate inbox
to get Id
and ChangeKey
properties (in lieu of relying on names)
<FindFolder Traversal='Shallow' xmlns='http://schemas.microsoft.com/exchange/services/2006/messages'>
<FolderShape>
<t:BaseShape>Default</t:BaseShape>
</FolderShape>
<ParentFolderIds>
<t:DistinguishedFolderId Id='inbox'>
<t:Mailbox>
<t:EmailAddress>[email protected]</t:EmailAddress>
</t:Mailbox>
</t:DistinguishedFolderId>
</ParentFolderIds>
</FindFolder>
Next, I use an Id
and ChangeKey
of an email found in the inbox
and the Id
and ChangeKey
of the folder found above to attempt the move
<m:MoveItem>
<m:ToFolderId>
<FolderId Id='folder.Id' ChangeKey='folder.ChangeKey'>
<t:Mailbox>
<t:EmailAddress>[email protected]</t:EmailAddress>
</t:Mailbox>
</FolderId>
</m:ToFolderId>
<m:ItemIds>
<t:ItemId Id='email.Id' ChangeKey='email.ChangeKey' />
</m:ItemIds>
</m:MoveItem>
To me this would work, but after looking at the docs it appears <FolderId>
elements do not allow for a <t:Mailbox>
child.
<t:DistinguishedFolderId>
does allow for <t:Mailbox>
, but I can only select from a list of previously identified folders and not user-defined ones. Is there a way to tell the <MoveItem>
call that all of these actions are happening on a delegate email?
Update (Working):
<MoveItem xmlns='http://schemas.microsoft.com/exchange/services/2006/messages' xmlns:t='http://schemas.microsoft.com/exchange/services/2006/types'>
<ToFolderId>
<t:FolderId Id='folder.Id' ChangeKey='folder.ChangeKey' />
</ToFolderId>
<ItemIds>
<t:ItemId Id='item.Id' ChangeKey='item.ChangeKey' />
</ItemIds>
</MoveItem>
Upvotes: 0
Views: 159
Reputation: 22032
The FolderId's you got back from your FindFolder request all relate to the delegates mailbox (if the parent was specified like you example). FolderId's are globally unique (a little more about that can be found https://msdn.microsoft.com/en-us/library/office/dn605828(v=exchg.150).aspx) so you don't need to specify the Mailbox you want to access as this information is included in the FolderId itself. The reason the Mailbox element exists in the DistinishedFolderId is that this allows you to access the WellKnownFolders in a Delegates Mailbox (without needing to make any other requests)
Upvotes: 1