问题
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