0
votes

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?

3
Do you mean that you have a normal date value, but its precision is to the second, rather than the millisecond? – Llama
Precision set Milliseconds but still cant find millisecond in DateTimeSent – jayrag pareek

3 Answers

1
votes

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;
0
votes

how about actually measuring the Timespan? so for example showing total milliseconds but you could change that to suit

var result=((TimeSpan)(DateTimeReceived  - DateTimeSent )).TotalMilliseconds.ToString("#,##0.00") + "ms";
0
votes

In the EWS Managed API the ExchangeService class has a precision property that you need to set before you make any calls see https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.exchangeservice.datetimeprecision(v=exchg.80).aspx