<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><title>Here is a working exchange example</title>
</head>
<body>
<font face="Calibri, Verdana, Helvetica, Arial"><span style="font-size:11pt">Thanks to all those that helped!<br>
<br>
Here is a very basic example to talk to exchange. Be aware that you also have to patch the Services.wsdl file to include these lines:<br>
Put these lines at the bottom of Services.wsdl before the closing </wsdl:definitions>:<br>
<br>
<wsdl:service name="ExchangeWebService"><br>
<wsdl:port name="ExchangeWebPort" binding="tns:ExchangeServiceBinding"><br>
<soap:address location="<a href="https://mail.gemini.edu/EWS/Exchange.asmx"></soap:address">https://mail.gemini.edu/EWS/Exchange.asmx"></soap:address</a>><br>
</wsdl:port><br>
</wsdl:service><br>
<br>
The first xml definition and attr = c.service.CreateItem(__inject={'msg':xml}) call will generate an email.<br>
The second xml definition and attr = c.service.ResolveNames(__inject={'msg':t}) will perform a user lookup<br>
<br>
import suds<br>
from suds.client import Client<br>
from suds.transport.https import WindowsHttpAuthenticated<br>
<br>
import logging<br>
logging.basicConfig(level=logging.INFO)<br>
logging.getLogger('suds.client').setLevel(logging.DEBUG)<br>
<br>
<br>
url = "<a href="file:///path/to/Services.wsdl">file:///path/to/Services.wsdl</a>"<br>
user = 'DOMAIN\user'<br>
password = "pass"<br>
<br>
ntlm = WindowsHttpAuthenticated(username=user,password=password)<br>
c = Client(url, transport=ntlm)<br>
<br>
xml = '''<br>
<soap:Envelope xmlns:soap="<a href="http://">http://</a>schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>" xmlns:xsd="<a href="http://www.w3.org/2001/XMLSchema"">http://www.w3.org/2001/XMLSchema"</a>><br>
<soap:Body><br>
<CreateItem MessageDisposition="SendAndSaveCopy" xmlns="<a href="http://">http://</a>schemas.microsoft.com/exchange/services/2006/messages"><br>
<SavedItemFolderId><br>
<DistinguishedFolderId Id="sentitems" xmlns="<a href="http://">http://</a>schemas.microsoft.com/exchange/services/2006/types"/><br>
</SavedItemFolderId><br>
<Items><br>
<Message xmlns="<a href="http://">http://</a>schemas.microsoft.com/exchange/services/2006/types"><br>
<ItemClass>IPM.Note</ItemClass><br>
<Subject>Sent via Python->Exchange->EWS</Subject><br>
<Body BodyType="Text">This message has been sent to you via Python, Exchange and EWS :)</Body><br>
<ToRecipients><br>
<Mailbox><br>
<EmailAddress><a href="jeckersley@gemini.edu</EmailAddress">jeckersley@gemini.edu</EmailAddress</a>><br>
</Mailbox><br>
</ToRecipients><br>
</Message><br>
</Items><br>
</CreateItem><br>
</soap:Body></soap:Envelope>'''<br>
#attr = c.service.CreateItem(__inject={'msg':xml})<br>
<br>
xml = '''<br>
<soap:Envelope xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>" xmlns:xsd="<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>" xmlns:soap="<a href="http://">http://</a>schemas.xmlsoap.org/soap/envelope/" xmlns:t="<a href="http://">http://</a>schemas.microsoft.com/exchange/services/2006/types"><br>
<soap:Body><br>
<ResolveNames xmlns="<a href="http://">http://</a>schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="<a href="http://">http://</a>schemas.microsoft.com/exchange/services/2006/types" ReturnFullContactData="true"><br>
<UnresolvedEntry>jeckersley</UnresolvedEntry><br>
</ResolveNames><br>
</soap:Body><br>
</soap:Envelope><br>
'''<br>
attr = c.service.ResolveNames(__inject={'msg':t})<br>
<br>
print attr</span></font>
</body>
</html>