Howto: Read OOF info using EWS and VBScript against an Exchange 2010 SP1
' Here is a code sample showing how to read OOF info using EWS from VBScript against an Exchange 2010 SP1 box.
Const strUrl = "https://mail.mycompanyetc.com/ews/exchange.asmx" ' TODO: Change
Const strUser = "myuserid" ' TODO: Change
Const strPass = "mypassword"
Const strDom = "myusersdomain" ' TODO: Change
Const strEmailAddress = "myemailaddress@myemaildomain.com" ' TODO: Change
Dim oXml
Dim xmlDoc
Dim strXmlData
Set oXml = CreateObject("MSXML2.XMLHTTP")
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
strXmlData = strXmlData & "<?xml version=""1.0"" encoding=""utf-8"" ?> "
strXmlData = strXmlData & "<soap:Envelope xmlns:xsi=""https://www.w3.org/2001/XMLSchema-instance"" "
strXmlData = strXmlData & "xmlns:m=""https://schemas.microsoft.com/exchange/services/2006/messages"" "
strXmlData = strXmlData & "xmlns:t=""https://schemas.microsoft.com/exchange/services/2006/types"" "
strXmlData = strXmlData & "xmlns:soap=""https://schemas.xmlsoap.org/soap/envelope/"">"
strXmlData = strXmlData & "<soap:Header>"
strXmlData = strXmlData & " <t:RequestServerVersion Version=""Exchange2010_SP1"" /> "
strXmlData = strXmlData & "</soap:Header>"
strXmlData = strXmlData & "<soap:Body>"
strXmlData = strXmlData & " <m:GetUserOofSettingsRequest>"
strXmlData = strXmlData & " <t:Mailbox>"
strXmlData = strXmlData & " <t:Address>"&strEmailAddress &"</t:Address> "
strXmlData = strXmlData & " </t:Mailbox>"
strXmlData = strXmlData & " </m:GetUserOofSettingsRequest>"
strXmlData = strXmlData & " </soap:Body>"
strXmlData = strXmlData & "</soap:Envelope>"
oXml.open "POST", strUrl, False, strDom & "\" & strUser, strPass
oXml.setRequestHeader "Content-Type", "text/xml"
oXml.send strXmlData
If oXml.Status = "200" Then
If xmlDoc.loadXML(oXml.responseText) Then
If xmlDoc.documentElement.getElementsByTagName("ResponseMessage").Item(0).Attributes.getNamedItem("ResponseClass").Text = "Success" Then
wscript.echo "Reply: " & oXml.responseText
Else
wscript.echo "Could not get OOF info" & vbCrLf & xmlDoc.xml
End If
End If
Else
wscript.echo "Error: " & oXml.Status & " - " & oXml.statusText
End If