We are encountering an issue with EWS 2.2 Managed API(and previous versions) and attachment names. EWS exposes two potential fields for an attachment name. Name, and FileName. In our findings, Name can sometimes report the same file name we see in mail clients (such as Outlook), and FileName is always black (Nothing in VB.NET).
The XML request and responses are output from the "ExchangeService.TraceEnabled = True" and "ExchangeService.TraceFlags = TraceFlags.All" options.
XML request example:
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <t:RequestServerVersion Version="Exchange2010_SP2" /> </soap:Header> <soap:Body> <m:GetItem> <m:ItemShape> <t:BaseShape>IdOnly</t:BaseShape> <t:AdditionalProperties> <t:FieldURI FieldURI="item:Attachments" /> </t:AdditionalProperties> </m:ItemShape> <m:ItemIds> <t:ItemId Id="biglongItemId" /> </m:ItemIds> </m:GetItem> </soap:Body> </soap:Envelope>
EWS XML response:
<?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="195" MinorBuildNumber="1" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> </s:Header> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <m:GetItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> <m:ResponseMessages> <m:GetItemResponseMessage ResponseClass="Success"> <m:ResponseCode>NoError</m:ResponseCode> <m:Items> <t:Message> <t:ItemId Id="biglongItemId" ChangeKey="CQAAABYAAAB6Lqmbg0p2SpXlhlOVcY4TAAAnDxiX" /> <t:Attachments> <t:FileAttachment> <t:AttachmentId Id="biglongAttachmentId" /> <t:Name>body.csv</t:Name> <t:ContentType>text/plain</t:ContentType> <t:ContentId>{6981D03B-2EBD-4F8F-BF8D-61424696F792}</t:ContentId> <t:Size>135</t:Size> <t:LastModifiedTime>2014-01-03T02:13:44</t:LastModifiedTime> <t:IsInline>false</t:IsInline> <t:IsContactPhoto>false</t:IsContactPhoto> </t:FileAttachment> </t:Attachments> </t:Message> </m:Items> </m:GetItemResponseMessage> </m:ResponseMessages> </m:GetItemResponse> </s:Body> </s:Envelope>
In the example above, Name is body.csv. FileName as nothing. In Outlook, the attachment file name is "CUSTOMER.CSV".
I have confirmed with the sender that file attachment file is named "CUSTOMER.CSV".
Can anyone provide some insight into why EWS reports a file name that is not what was provided by the sender?
Thanks much in advance.