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

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

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

问题

在我的应用程序中,我需要查询Exchange Web Services服务器并找到所有未读消息。我正在使用Golang发送SOAP XML请求。我尝试了以下代码:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
  4. xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
  5. xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  6. <soap:Header>
  7. <t:RequestServerVersion Version="Exchange2013_SP1" />
  8. </soap:Header>
  9. <soap:Body>
  10. <m:FindItem
  11. Traversal="Shallow">
  12. <m:ItemShape>
  13. <t:BaseShape>IdOnly</t:BaseShape>
  14. </m:ItemShape>
  15. <m:Restriction>
  16. <t:IsEqualTo>
  17. <t:FieldURI FieldURI="item:IsRead" />
  18. <t:FieldURIOrConstant>
  19. <t:Constant Value="false" />
  20. </t:FieldURIOrConstant>
  21. </t:IsEqualTo>
  22. </m:Restriction>
  23. <m:ParentFolderIds>
  24. <t:DistinguishedFolderId Id="inbox" />
  25. </m:ParentFolderIds>
  26. </m:FindItem>
  27. </soap:Body>
  28. </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:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
  4. xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
  5. xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  6. <soap:Header>
  7. <t:RequestServerVersion Version="Exchange2013_SP1" />
  8. </soap:Header>
  9. <soap:Body>
  10. <m:FindItem
  11. Traversal="Shallow">
  12. <m:ItemShape>
  13. <t:BaseShape>IdOnly</t:BaseShape>
  14. </m:ItemShape>
  15. <m:Restriction>
  16. <t:IsEqualTo>
  17. <t:FieldURI FieldURI="item:IsRead" />
  18. <t:FieldURIOrConstant>
  19. <t:Constant Value="false" />
  20. </t:FieldURIOrConstant>
  21. </t:IsEqualTo>
  22. </m:Restriction>
  23. <m:ParentFolderIds>
  24. <t:DistinguishedFolderId Id="inbox" />
  25. </m:ParentFolderIds>
  26. </m:FindItem>
  27. </soap:Body>
  28. </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中使用搜索过滤器中复制的示例:

  1. <t:IsEqualTo>
  2. <t:FieldURI FieldURI="message:IsRead" />
  3. <t:FieldURIOrConstant>
  4. <t:Constant Value="false" />
  5. </t:FieldURIOrConstant>
  6. </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
:

  1. &lt;t:IsEqualTo&gt;
  2. &lt;t:FieldURI FieldURI=&quot;message:IsRead&quot; /&gt;
  3. &lt;t:FieldURIOrConstant&gt;
  4. &lt;t:Constant Value=&quot;false&quot; /&gt;
  5. &lt;/t:FieldURIOrConstant&gt;
  6. &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:

确定