我试图通过EWS使用python,ewsclient和sud-ews在Exchange 2007中搜索电子邮件,根据我在网上找到的内容,我已经提出以下代码:
import ewsclient
import suds.client
import logging
from suds.transport.https import WindowsHttpAuthenticated
email = 'me@mycompany.com'
domain = 'webmail.mycompany.com'
username = r'mycompany\me'
password = 'Password'
transport = WindowsHttpAuthenticated(username=username,password=password)
client = suds.client.Client("https://%s/EWS/Services.wsdl" % domain,transport=transport,plugins=[ewsclient.AddService(),MyPlugin()])
mfrst = client.factory.create('ns1:ItemResponseShapeType')
mfrst.BaseShape = "IdOnly"
cvt = client.factory.create('ns1:ConstantValueType')
cvt._Value = "XXX"
cet = client.factory.create('ns1:ContainsExpressionType')
cet.Constant = cvt
cet._ContainmentComparison = "IgnoreCase"
cet._ContainmentMode = "Substring"
mrt = client.factory.create('ns1:RestrictionType')
mrt.SearchExpression = cet
fot = client.factory.create('ns1:FieldOrderType')
fot._Order = "Descending"
stor = client.factory.create('ns1:NonEmptyArrayOfFieldOrdersType')
stor.FieldOrder.append(fot)
mtdfit = client.factory.create('ns1:DistinguishedFolderIdType')
mtdfit._Id = "inbox"
gfrt = client.service.FindItem(mfrst,mrt,stor,mtdfit)
但我得到的是以下错误: WebFault:服务器引发的错误:'请求未通过架构验证:缺少必需的属性'Traversal'。'
在自述文件中我可以看到sud-ews 添加了在调用期间指定方法属性的功能 - '_' - 前缀参数,但我无法弄清楚如何使用它