php小编百草在这里向大家介绍一种利用Exchange Web服务的方法,通过使用SOAP XML请求来查找所有未读消息。Exchange Web服务是一种用于与Exchange Server通信的API,它提供了访问和管理电子邮件、日历、联系人等功能的能力。通过使用SOAP XML请求,我们可以向Exchange Server发送请求,并获取返回的数据。在这篇文章中,我们将详细介绍如何使用SOAP XML请求来查找所有未读消息。
问题内容
在我的应用程序中,我需要查询 echange web 服务服务器并查找所有未读消息。我正在使用 golang,并且正在发送soap xml 请求。我尝试了以下方法:
<?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:Constant Value="false" />
</t:FieldURIOrConstant>
</t:IsEqualTo>
</m:Restriction>
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="inbox" />
</m:ParentFolderIds>
</m:FindItem>
</soap:Body>
</soap:Envelope>
但在这种情况下,我收到错误消息,表明我的请求不正确。如果我删除
,我会在收件箱中收到所有消息。任何如何修复它的想法都将受到欢迎。谢谢
解决方法
根据 fielduri 属性列表,item:isread
应为 message:isread
。以下是从 ews 中的平等过滤器
一>:
<t:IsEqualTo>
<t:FieldURI FieldURI="message:IsRead" />
<t:FieldURIOrConstant>
<t:Constant Value="false" />
</t:FieldURIOrConstant>
</t:IsEqualTo>