0 votes
by (180 points)

I use the following source code to set the start date to 09/01/2023 and the due date to 15/01/2023.

DateTime startDate = new DateTime(2023, 01, 9);
DateTime dueDate = new DateTime(2023, 01, 15);
EwsFlag ewsFlag = new EwsFlag(EwsFlagStatus.Flagged, startDate, dueDate, null);
EwsMessageMetadata ewsMessageMetadata = new EwsMessageMetadata();
ewsMessageMetadata.Flag = ewsFlag;
ewsClient.UpdateItemMessage(ewsMessageInfo.Id, ewsMessageMetadata);

However, the result in the email was the start date 08/01/2023 and the due date 14/01/2023. (Flag for follow up. Start by Sunday 8 January 2023 Due by Saturday 14 January 2023)

Why? Unfortunately, I do not understand this.

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (64.5k points)

Do you mean that when you immediately call the ewsClient.GetMessageInfo() to retrieve the updated item the dates are wrong?

It is only my guess, but I think you are updating the item programmatically, but you are viewing the update item in a GUI application. Please note that the date and times are stored at the server in UTC, but they are displayed in process/application local time. It means that if you update the item on a computer in time zone -4, but you are viewing the item in an application which is configured to display times in time zone -5 you see different date, because your 2023-01-15 00:00:00 is displayed as 2023-01-14 23:00:00 at the application.

It seems that you are not interested in the time part. In such case, I suggest you to set the DateTime with 12h UTC like this:

new DateTime(2023, 01, 15, 12, 0, 0, DateTimeKind.Utc);

If my guess is wrong and you are facing different issue, please describe it in more details.