Jayrag Pareek
Jayrag Pareek

Reputation: 374

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?

Upvotes: 0

Views: 684

Answers (3)

Jayrag Pareek
Jayrag Pareek

Reputation: 374

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;

Upvotes: 1

Glen Scales
Glen Scales

Reputation: 22032

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

Upvotes: 0

jazb
jazb

Reputation: 5791

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";

Upvotes: 0

Related Questions