Exchange Web Services查询未读邮件SOAP请求报错求助
解决EWS查询未读邮件的SOAP请求错误问题
问题根源
你的请求里用了<t:Constant>传递布尔值,但EWS对item:IsRead这类布尔类型字段,要求使用专门的<t:BoolConstant>节点而非通用的<t:Constant>,这是导致请求报错的核心原因。
修正后的SOAP请求
<?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="Exchange2013_SP1" /> </soap:Header> <soap:Body> <m:FindItem Traversal="Shallow"> <m:ItemShape> <t:BaseShape>IdOnly</t:BaseShape> </m:ItemShape> <m:Restriction> <t:IsEqualTo> <t:FieldURI FieldURI="item:IsRead" /> <t:FieldURIOrConstant> <t:BoolConstant Value="false" /> </t:FieldURIOrConstant> </t:IsEqualTo> </m:Restriction> <m:ParentFolderIds> <t:DistinguishedFolderId Id="inbox" /> </m:ParentFolderIds> </m:FindItem> </soap:Body> </soap:Envelope>
额外验证点
- 确认Exchange服务器版本与
RequestServerVersion中的Exchange2013_SP1匹配,若服务器版本更高,可调整为对应版本(如Exchange2016) - 检查请求的HTTP头是否正确设置
Content-Type: text/xml; charset=utf-8,这是SOAP请求的必要配置
内容的提问来源于stack exchange,提问作者Jack
相关产品推荐
相关产品推荐

