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

眉间皱痕 提交于 2019-12-11 17:13:20

问题


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?


回答1:


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




回答2:


.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.



来源:https://stackoverflow.com/questions/46232750/how-to-get-the-millisecond-part-of-the-datetimerecieved-field-of-emailmessage-us

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!