Exchange Server TechCenter >
Exchange Server Forums
>
Unified Messaging
>
Failed to set the timestamp for the created message
Failed to set the timestamp for the created message
- Hi All,
I trying to create messages in my exchange mailbox with the exchange web services. Everything is working fine, when I create the message and save that, but I cannot set the "sent" or "received" date because getting the next error message: "Set action is invalid for property." . The code, what I use is the next:
If I comment out the msg.DateTimeReceivedSpecified = true; line then the message is creating, but the timestamp is the current time.private void ArchiveMsg(ExchangeUser user, string from, string to, string body) { MessageType msg = new MessageType(); msg.ToRecipients = new EmailAddressType[1]; msg.ToRecipients[0] = new EmailAddressType(); msg.ToRecipients[0].EmailAddress = to; msg.From = new SingleRecipientType(); msg.From.Item = new EmailAddressType(); msg.From.Item.EmailAddress = from; msg.Body = new BodyType(); msg.Body.BodyType1 = BodyTypeType.Text; msg.Body.Value = body; msg.DateTimeReceived = DateTime.Now.AddHours(-8); msg.DateTimeReceivedSpecified = true; CreateItemType createItem = new CreateItemType(); createItem.Items = new NonEmptyArrayOfAllItemsType(); createItem.Items.Items = new ItemType[1]; createItem.Items.Items[0] = msg; createItem.MessageDisposition = MessageDispositionType.SaveOnly; createItem.MessageDispositionSpecified = true; createItem.SavedItemFolderId = new TargetFolderIdType(); createItem.SavedItemFolderId.Item = GetFolder(esb, "some mailbox folder", "user@domain.com"); CreateItemResponseType response = esb.CreateItem(createItem); }
How can I set this property?
Thanks in advance,
Best Regards, Imre Kovács
All Replies
I am facing problem similar to the above context.
I am reading inbox folder mails from exchange mail server with the help of EWS. EWS is returning "DateTimeSent", "DateTimeCreated" values in GMT format. That's fine.
But EWS webservice(GetItem) is not retunring the property which is "DateTimeReceived". Its returning it as "{1/1/0001 12:00:00 AM}" which i guess is default start date value.
Code:
MessageType message = (MessageType)typ;
DateTime dtMailReceived = message.DateTimeReceived;
After tracing more properties, it was found that "DateTimeReceivedSpecified" property is "false". So is the "DateReceived" problem is because of "DateTimeReceivedSpecified" property is "false"? if yes, how to set this value to "true" for each and every mail before reading.
Anybody has the answer?


