OfficeDev / ews-java-api

A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
MIT License
870 stars 560 forks source link

InternetMessageHeaders data loss. I can't find 'Resent-From' #758

Closed godtrack closed 2 years ago

godtrack commented 2 years ago

I can find it in eml file, but I can't find it through EWS, why? service.loadPropertiesForItems(results, PropertySet.FirstClassProperties); InternetMessageHeader internetMessageHeader = item.getInternetMessageHeaders().find("Resent-From"); internetMessageHeader is null

image

godtrack commented 2 years ago

This is my original email 高考前一天,沅江市政府领导到考点开展考前督查.eml.txt

godtrack commented 2 years ago

I found a solution in the official documentation. https://docs.microsoft.com/zh-cn/exchange/client-developer/web-service-reference/internetmessageheader ExtendedPropertyDefinition PR_TRANSPORT_MESSAGE_HEADERS = new ExtendedPropertyDefinition(0x007D, MapiPropertyType.String); service.loadPropertiesForItems(findResults, new PropertySet(BasePropertySet.FirstClassProperties, PR_TRANSPORT_MESSAGE_HEADERS));

ExtendedPropertyCollection extendedProperties = item.getExtendedProperties(); OutParam<String> outParam = new OutParam<>(); extendedProperties.tryGetValue(String.class, PR_TRANSPORT_MESSAGE_HEADERS, outParam); String param = outParam.getParam(); This contains all the attributes of the mail