Modify Sender (or From address) of EmailMessage using EWS API

Hi,

I am trying to modify Sender (or From address) of public folder items. Though Sender and From properties are writable according to this document:

https://msdn.microsoft.com/en-us/library/office/dn600367(v=exchg.150).aspx

but EWS API is throwing error when I am trying to modify these properties.

When I am trying to modify 'From' field of email item, i m getting this error:

Exception: Message is not draft.

When I am trying to modify 'Sender' field of email item, i m getting this error:

Exception: This property can't be updated.

I also tested this with email items in Inbox folder of a mailbox, and faced same errors.

This is piece of code, I am using

foreach (Item item in findResults.Items)
{
   EmailMessage msg = item as EmailMessage;
  msg.Sender = new  EmailAddress("jt@mydomain.onmicrosoft.com");
//Also tried
//  msg.From= new  EmailAddress("jt@mydomain.onmicrosoft.com");
  msg.Update(ConflictResolutionMode.AutoResolve); 

 }

I am looking to find out some substitute method for this. Can anyone help.

Thanks in anticip

April 8th, 2015 11:30am

Those properties are only writable before the Item is committed to the Exchange store (eg  before either save, sent etc is called). You maybe able to change the sender using the Extended properties listed in https://msdn.microsoft.com/en-us/library/hh745482(v=exchg.80).aspx after commit.

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
April 9th, 2015 12:07am

Those properties are only writable before the Item is committed to the Exchange store (eg  before either save, sent etc is called). You maybe able to change the sender using the Extended properties listed in https://msdn.microsoft.com/en-us/library/hh745482(v=exchg.80).aspx after commit.

Cheers
Glen

April 9th, 2015 4:05am

Hi,

Thanks Glen for your reply. I am going to test it with Extended property you mentioned. I would update this thread with my result in next few hours.

Free Windows Admin Tool Kit Click here and download it now
April 9th, 2015 10:47am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics