tavier
tavier

Reputation: 1794

How to get the millisecond part of the DateTimeRecieved field of emailmessage using EWS managed APIs

I have a code which synchronizes with exchange and gets the emailmessage objects for the given itemids:

List<EmailMessage> emails = new List<EmailMessage>();
            ServiceResponseCollection<GetItemResponse> response =
                            MyExchangeService.BindToItems(MyItemIds, PropertySet);
            foreach (GetItemResponse getItemResponse in response)
            {
                if (getItemResponse.Item != null)
                {
                    emails.Add((EmailMessage)getItemResponse.Item);
                }
            }

Now, the emailmessage object that I get as a result, contains the DateTimeReceived property as 9/15/2017 5:27:16 AM whereas I would like it to contain the millisecond part of the time as well. Is it possible?

Upvotes: 0

Views: 725

Answers (2)

Glen Scales
Glen Scales

Reputation: 22032

You need to set the precision on the ExchangeService class see https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.exchangeservice.datetimeprecision(v=exchg.80).aspx to millisecond before you make the call

Upvotes: 5

Grisgram
Grisgram

Reputation: 3243

.DateTimeReceived is a normal DateTime field, so you have Ticks and every other standard way to analyze that value.

In your case,

message.DateTimeReceived.Millisecond

should give you what you are looking for.

Upvotes: 1

Related Questions