Reputation: 301
I am working against the Exchange 2010 EWS Managed API and trying to update emails (EmailMessage
).
While updating the EmailMessage's Sender.Name
property, I get an exception upon Update()
, but if I try to update the EmailMessage's Subject
, it works just fine.
private void UpdateEmail(ItemId itemId)
{
try
{
EmailMessage emailMessage = EmailMessage.Bind(service, itemId, new PropertySet(EmailMessageSchema.Sender, EmailMessageSchema.Subject));
// Test 1 - this works:
emailMessage.Subject = "Testing";
emailMessage.Update(ConflictResolutionMode.AlwaysOverwrite);
// Test 2 - this does NOT work (if I comment out the previous 2 lines btw):
emailMessage.Sender.Name = "John Smith";
emailMessage.Update(ConflictResolutionMode.AlwaysOverwrite); // exception thrown
...
I get the following error from Test 2:
The request failed schema validation: The element 'Updates' in namespace 'http:/
/schemas.microsoft.com/exchange/services/2006/types' has incomplete content. Lis
t of possible elements expected: 'AppendToItemField, SetItemField, DeleteItemFie
ld' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.
Upvotes: 0
Views: 695
Reputation: 22032
EWS doesn't support changing the Sender address via the Strongly typed properties like you are trying. The only way they maybe successful is to modify the underlying extended properties and generating oneoff or wrapped entry-id where applicable the props you need to update are
PR_SENDER_ADDRTYPE_W
PR_SENDER_EMAIL_ADDRESS_W
PR_SENDER_NAME_W
PR_SENDER_ENTRYID
PR_SENDER_SEARCH_KEY
PR_SENT_REPRESENTING_EMAIL_ADDRESS_W
PR_SENT_REPRESENTING_ADDRTYPE_W
PR_SENT_REPRESENTING_NAME_W
PR_SENT_REPRESENTING_ENTRYID
PR_SENT_REPRESENTING_SEARCH_KEY
Note there maybe others as well you need to use a MAPI editor like OutlookSpy of MFCMapi to look at an item yourself.
Cheers Glen
Upvotes: 1