Search code examples
c#asp.net-mvcexchange-serverexchangewebservicesews-managed-api

EWS Managed API, Why Item.DateTimeSent.Millisecond is always zero?


I am trying to calculate the time taken to send email message and time taken to receive email message. i am using EWS in my program , I set streaming notification to receive call back when a new mail reaches reciptent mailbox .

once received notification i bind the Itemevent with ews service , i checked the item properties DateTimeCreated, DateTimeSent, DateTimeReceived.All these properties are of DateTime object.

I checked DateTimeSent milisecond is always 0, whereas DateTimeCreated, DateTimeReceived has millisecond value.

I couldnot figure out why DateTimeSent millisecond is always 0 everytime. if i want to claulate time taken from send to receive what should i do.

DateTimeReceived - Datetimesent is the actual time taken to send and receive the message?

or what is the correct way to calculate time taken to send and receive the message?


Solution

  • set DateTimePrecision as Milliseconds

       ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
        service.Credentials = new WebCredentials(username, password);
        service.Url = new Uri(ConfigSettings.EmailConnectionUrl);
        service.DateTimePrecision = DateTimePrecision.Milliseconds;