Home > Archive > MS SQL XML > November 2005 > XML with Exchange 2003









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author XML with Exchange 2003
skywalker

2005-11-04, 3:23 am

Hi, I am trying to have a vbscript to trigger the out of office state & msg
for exchange 2003 mail account. I uses xmlhttp to :
a. post a logon using owadll.
b. post a http request to the exchange options page.

The script seems to work as I can see the change to the OOf state and the
OOF msg; but the script would not exit as it seems to wait for something. I
have to issue a Ctrl Break/C to break it.

Also, when I use a http traffic sniffer to see the request, I saw that the
response to my 2nd post request was "(Status-Line):HTTP/1.1 302 Moved
Temporarily".

Need some pointers and help here, thanks.



Below is my code
================BEGI
N==============
Xmlstr = ""
Xmlstr = Xmlstr & "Cmd=Options" & vbLf
Xmlstr = Xmlstr & "OofReply=I am out from e " & Now() & vbLf
Xmlstr = Xmlstr & "OofState=1" & vbLf

Set req = CreateObject("Microsoft.XMLhttp")
servername = "server1"
mailbox = "test.testing11"
domain = "maildomain"
strpassword = "password1"
strusername = domain & "\" & mailbox
szXml = "destination=https://" & servername & "/exchange&flags=0&username="&
strusername
szXml = szXml & "&password=" & strpassword &
"&SubmitCreds=LogOn&forcedownlevel=0&trusted=0"
req.Open "post", "https://" & servername &
"/exchweb/bin/auth/owaauth.dll",False
req.send szXml

reqhedrarry = split(req. GetAllResponseHeader
s(), vbCrLf,-1,1)
for i = lbound(reqhedrarry) to ubound(reqhedrarry)
if instr(lcase(reqhedra
rry(i)),"set-cookie: sessionid=") then reqsessionID=
right(reqhedrarry(i)
,len(reqhedrarry(i))
-12)
if instr(lcase(reqhedra
rry(i)),"set-cookie: cadata=") then
reqcadata=right(reqh
edrarry(i),len(reqhe
drarry(i))-12)
next

if reqsessionID ="" then
Wscript.echo "Unable to logon to server; Please retry "
set req=NOTHING
wscript.quit
end if

req.Open "POST", "https://" & servername & "/exchange/" & mailbox &
"/?cmd=options",FALSE, "", ""
req.setRequestHeader "Accept-Language:", "en-us"
req.setRequestHeader "Content-type:", "application/x-www-UTF8-encoded"
req.SetRequestHeader "cookie", reqsessionID
req.SetRequestHeader "cookie", reqCadata
req.setRequestHeader "Content-Length:", Len(Xmlstr)
req.Send Xmlstr

If req.Status = 200 Then
Wscript.Echo "Out Of Office Enable at " & servername & " Sucessfully"
WScript.Echo "Https status code =" & req.status
Wscript.Echo req.responsetext
Elseif req.responsetext ="" Then
WScript.Echo "It seems an error occured during the Send Command. Are
you sure you have the correct permissions on this mailbox ?"
WScript.Echo "Response of the server was " & req.responsetext
Else
WScript.Echo "Out of Office enabled for mailbox " & mailbox & "Fail !"
Wscript.Echo req.responsetext
End If

Set req = Nothing
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com