Click to See Complete Forum and Search --> : Webdav and exchange
Funkymonkey
10-26-2005, 06:29 AM
I'm not sure where to post this so here goes:
I need to access the emails in a folder in outlook and save the subject along with the message id into a database. I have some code that displays the subjects of the emails so far but am not sure where to go from here. Does anyone have any ideas or want to see some code???
Thanks!
LiLcRaZyFuZzY
10-26-2005, 06:52 AM
yep, please post your code
Funkymonkey
10-26-2005, 06:56 AM
<script language="VBScript">
Dim objXMLHTTP, objXMLDoc
' Define your protocol; http or https
strProtocol = "http"
' Define your server name
strServername = "mail"
' Define your local name for 'Inbox'
strInbox = "Inbox/IT"
'Displays the status code of the response on the screen, and prepares the returned XML response for display by the
'XSL code in responseXSL
Sub getMessages_OnClick()
strUsername = document.all.mailbox.value
If strUsername <> "" Then
strInboxURL = strProtocol & "://" & strServername & "/Exchange/"
strInboxURL = strInboxURL & strUsername & "/" & strInbox
Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "SEARCH", strInboxURL, True
objXMLHTTP.setRequestHeader "Content-type:", "text/xml"
objXMLHTTP.setRequestHeader "Depth", "1"
objXMLHTTP.onReadyStateChange = getRef("checkXMLHTTPState")
strXML = "<?xml version='1.0' ?>" & _
"<a:searchrequest xmlns:a='DAV:'><a:sql>" & _
"SELECT" & _
" ""DAV:href""" & _
",""urn:schemas:httpmail:subject""" & _
" FROM scope('shallow traversal of """ & strInboxURL & """')" & _
" WHERE ""DAV:ishidden""=False" & _
" AND ""DAV:isfolder""=False" & _
"</a:sql></a:searchrequest>"
objXMLHTTP.SetRequestHeader "Range", "rows=0-50"
objXMLHTTP.Send(strXML)
End If
End Sub
Sub checkXMLHTTPState
If objXMLHTTP.readyState = 4 Then
responseStatus.innerHTML = objXMLHTTP.Status & " - " & objXMLHTTP.StatusText
Set objXMLDoc = objXMLHTTP.ResponseXML
XSLDiv.innerHTML = objXMLDoc.TransformNode(responseXSL.documentElement)
Set objXMLHTTP = Nothing
Set objXMLDoc = Nothing
End If
End Sub
</script>
Funkymonkey
10-26-2005, 06:57 AM
<xml id="responseXSL">
<xsl:template xmlns:xsl='uri:xsl' xmlns:a='DAV:' xmlns:e='urn:schemas:mailheader:' xmlns:d='urn:schemas:httpmail:'>
<table border="1" cellpadding="5">
<!--Add a row for each element in the 207 Multistatus response to the SEARCH request. -->
<xsl:for-each select='a:multistatus/a:response'>
<tr>
<!-- Build a hyperlink using the resource href and subject -->
<td>
<a>
<xsl:attribute name='href'>
<xsl:value-of select='a:propstat/a:prop/a:href' />/?Cmd=open
</xsl:attribute>
<xsl:attribute name='target'>_blank</xsl:attribute>
<xsl:value-of select='a:propstat/a:prop/d:subject' />
</a>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xml>
</HEAD>
<body>
<font face="Verdana" size="2">Mailbox name:<br>
<input type="text" name="mailbox">
<br>
<input type="button" value=" GO " name="getMessages">
<br>
<div id="responseStatus"></div>
<div id="XSLDiv"></div><!--This is a placeholder for the table that's created-->
</font>
Funkymonkey
10-26-2005, 07:00 AM
The faces are a : and a P :)