I have to have somthing wrong in the OpenMessage function.
you have to run the script on the exchange server, under an account that has access to the mail box in question. the get messages function is working great, it walked the entire inbox folder with no problem.
Code:
break on
main
Function Main()
GetMessages("file://./BackOfficeStorage/<DOMAIN>/MBX/<USERID>/Inbox/")
EndFunction
function GetMessages($szURL)
dim $oConn, $oRS
$oConn = createobject("ADODB.Connection")
$oRS = createobject(ADODB.RecordSet)
Dim $szQuery
;this is a vbscript line crazy quotes?!?!?
;szQuery = "SELECT ""DAV:href"", ""urn:schemas:httpmail:subject"" FROM SCOPE('shallow traversal of """ & szURL & """')"
;kix version??
$szQuery = 'SELECT "DAV:href", "urn:schemas:httpmail:subject" FROM SCOPE(' + "'shallow traversal of " + '"'+ $szURL + '"' +"')"
? $szQuery
$oConn.ConnectionString = $szURL
$oConn.Provider = "EXOLEDB.DataSource"
$oConn.Open
$oRS.Open($szQuery, $oConn)
While not $oRS.EOF
; Do Something with this item
? $oRS.Fields("urn:schemas:httpmail:subject").Value ;Dump the message Subject
? $oRS.Fields("DAV:href").Value ;Dump the url to the message Item
; Now Open the MEssage
OpenMessage($oRS.Fields("DAV:href").Value, $oConn)
$oRS.MoveNext
Loop
$oConn = 0
$oRS = 0
Endfunction
;something is wrong with this function, errors.
function OpenMessage($szUR, $oConn)
debug on
dim $oMsg
$oMsg = createobject("CDO.Message") ? @error
; Bind to the Message Item
$oMsg.DataSource.Open($szURL, $oConn)
? @error " " @serror
; Dump some of the message properties
? $oMsg.Subject " " @error " " @serror
? $oMsg.From" " @error " " @serror
? $oMsg.To" " @error " " @serror
$oMsg = 0
Endfunction