Exchange Web Services – 使用 SOAP XML 请求查找所有未读邮件

huangapple go评论80阅读模式
英文:

Exchange web services - find all unread messages with soap xml request

问题

在我的应用程序中,我需要查询Exchange Web Services服务器并找到所有未读消息。我正在使用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>

但是在这种情况下,我收到错误消息说我的请求不正确。如果我删除<t:IsEqualTo>,我会得到收件箱中的所有消息。有什么办法可以修复这个问题吗?谢谢。

英文:

in my app I need to query Echange web services server and find all unread messages. I am using Golang and I am sending soap xml requests. I tried the following:

<?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>

but in this case I get error saying that my request is incorrect. If I remove <t:IsEqualTo>, I get all messages in my inbox. Any ideas how to fix it would be welcome. Thank you

答案1

得分: 2

根据FieldURI属性列表item:IsRead应该是message:IsRead。以下是从在EWS中使用搜索过滤器中复制的示例:

<t:IsEqualTo>
  <t:FieldURI FieldURI="message:IsRead" />
  <t:FieldURIOrConstant>
    <t:Constant Value="false" />
  </t:FieldURIOrConstant>
</t:IsEqualTo>
英文:

According to the list of FieldURI Attribute, item:IsRead should be message:IsRead. Below is the example copied from Equality filter in EWS
:

&lt;t:IsEqualTo&gt;
  &lt;t:FieldURI FieldURI=&quot;message:IsRead&quot; /&gt;
  &lt;t:FieldURIOrConstant&gt;
    &lt;t:Constant Value=&quot;false&quot; /&gt;
  &lt;/t:FieldURIOrConstant&gt;
&lt;/t:IsEqualTo&gt;

huangapple
  • 本文由 发表于 2023年4月13日 01:13:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75998188.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定