locked
fail to load result into xmldatadocument RRS feed

  • Question

  • Dear All,


    I am having problem with retrieving emails from remote exchange server. With the sample code below, it does not works if i add the searchrequest to the send statement but it works if not.

    'this one working and give everything from under the specific mail box
    .send()
    Str = oXmlHttp.responseText
    ''Load the read mails into XML document'''
    xmlDOMParams.LoadXml(Str)

    'this one does not working, it false when i try to load the response text into a xml data dcoument.
    .send(strSQL)
    Str = oXmlHttp.responseText
    'Load the read mails into XML document'''
    xmlDOMParams.LoadXml(Str) 'here is the problem occurs



    Error message:
    System
    5
    The underlying connection was closed: unable to connect to the remote server.


    Does anyone has idea about that?

    Thanks


    Public Sub test2()
    Try
    Dim oXmlHttp As New MSXML2.ServerXMLHTTP40
    Dim xmlDOMParams As New System.Xml.XmlDataDocument
    Dim xmlDOMParamsAttachement As New MSXML2.DOMDocument40
    Dim xmlNdLstDonation, xmlNdLstDonation1, xmlNdListHasAttach As XmlNodeList
    Dim PropstatNodes As System.Xml.XmlNodeList
    Dim HrefNodes As System.Xml.XmlNodeList
    Dim StatusNode As System.Xml.XmlNode
    Dim PropNode As System.Xml.XmlNode

    Dim connectingURL As String = "http://Domain/exchange/tester/inbox"

    Dim UserName As String = "tester"
    Dim PWD As String = "12345"
    Dim Str As String
    Dim strSQL As String

    With oXmlHttp
    .open("PROPFIND", connectingURL, False, UserName, PWD)

    strSQL = "<?xml version='1.0' ?>" & _
    " <a:searchrequest xmlns:a='DAV:'><a:sql>" & _
    " SELECT " & _
    " ""DAV:href"" " & _
    " FROM scope('shallow traversal of """ & connectingURL & """')" & _
    " WHERE ""DAV:ishidden""=False" & _
    " AND ""DAV:isfolder""=False" & _
    "</a:sql></a:searchrequest>"

    .setRequestHeader("Depth", "1")
    .setRequestHeader("Content-type", "xml")
    .send(strSQL)

    Str = oXmlHttp.responseText
    ''Load the read mails into XML document'''
    xmlDOMParams.LoadXml(Str)

    Catch ex As Exception
    MsgBox(ex.Source & vbNewLine & Err.Number & vbNewLine & ex.Message, vbOKOnly, "readRemoteEmail")
    End Try
    End Sub
    Thursday, November 9, 2006 10:48 PM

Answers

  • Most likely exception happens before you call Load().

    Can you verify this and provide stack trace?

    Sunday, November 26, 2006 9:11 PM