怎样用asp提取指定Exchange文件夹中的所有文件和内容(以及附件)。
兄弟们:
有没有招-- 用asp提取指定Exchange文件夹中的所有文件和内容(以及附件)?
问题点数:20、回复次数:3Top
1 楼acptdta(微软全球技术中心 桌面产品技术支持)回复于 2002-04-16 20:46:41 得分 10
Visual Basic
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Server Library
' ..
Dim Rec As New ADODB.Record
Dim Rs As New ADODB.Recordset
Dim strURLInbox As String
strURLMailbox = "file://./backofficestorage/microsoft.com/MBX/user1/"
Rec.Open strURLMailbox
sURLInbox = Rec.Fields("urn:schemas:httpmail:inbox")
Rec.Open sURLInbox, Rec.ActiveConnection
Dim strView As String
strView = "select " _
& " ""DAV:HREF""" _
& ", ""DAV:content-class""" _
& ", ""urn:schemas:httpmail:datereceived""" _
& ", ""DAV:isfolder""" _
& ", ""DAV:getcontentlength""" _
& ", ""urn:schemas:httpmail:from""" _
& ", ""urn:schemas:httpmail:subject""" _
& ", ""urn:schemas:mailheader:importance""" _
& ", ""urn:schemas:httpmail:hasattachment""" _
& ", ""urn:schemas:httpmail:read""" _
& " from scope ('shallow traversal of """ _
& strURLInbox & """') " _
& " WHERE ""DAV:isfolder"" = false AND ""DAV:ishidden"" = false" _
& " ORDER BY ""urn:schemas:httpmail:datereceived"" DESC"
Rs.Open strView, Rec.ActiveConnection
If Rs.RecordCount = 0 Then
' no items in inbox
Else
Rs.MoveFirst
While Not Rs.EOF
' render view data here
Rs.MoveNext
Wend
End If
Top
2 楼acptdta(微软全球技术中心 桌面产品技术支持)回复于 2002-04-16 20:47:55 得分 10
感谢您使用微软产品。
我们可以用Ado对象模型来访问Exchange server (The Microsoft OLE DB Provider for Internet Publishing allows you to open folders and documents into ADO records and ADO recordsets.)
一条ADOrecord object 可以代表数据库中表中的一条记录,一个存在Exchange server中的文件,或Exchange server中一个被打开的目录。 ADO stream对象代表一个在内存中的文件,它可以被用来显示一个记录中包涵的文件:
下面是一个VBS的例子,该函数获得一 邮箱中邮件的URL, 取得 item's stream, 并把它存到磁盘上的一个文件中去.
VBScript
<job id="getstream">
<reference object="adodb.record"/>
<script language="vbscript">
Dim Stm
Dim Conn
Dim InfoNT
Dim sUrl
Dim sRelPath
Set InfoNT = CreateObject("WinNTSystemInfo")
sRelPath = "/public/test_folder/item4.txt"
sUrl = "http://" & InfoNT.Computername & sRelPath
Set Conn = CreateObject("ADODB.Connection")
Conn.Provider = "ExOLEDB.DataSource"
Conn.Open sUrl
Set Stm = getStream(sUrl, Conn)
If Stm.Type = adTypeText Then
Wscript.echo Stm.ReadText
End If
' ...
'''''''''''''''''''''''''''''''''''''''
' getStream
' sUrl - URL to item
' Conn - Active Connection or Nothing
'
'''''''''''''''''''''''''''''''''''''''
Function getStream( sUrl, Conn)
Dim Rec
Dim Flds
Dim sContentType
Set Rec = CreateObject("ADODB.Record")
' Did caller pass a Connection object reference?
If Not ( VarType(Conn) = vbObject AND TypeName(Conn) = "Connection" ) Then
Set Conn = CreateObject("ADODB.Connection")
Conn.Provider = "ExOLEDB.DataSource"
Conn.Open sUrl
End If
' Try to open the item
Rec.Open sUrl, Conn, adModeReadWrite
Set Flds = Rec.Fields
If Flds("DAV:isfolder") = True Or Flds("DAV:iscollection") = True Then
Err.Raise &H80070057, "GetStream", "Item at URL is a collection." ' E_INVALIDARG
End If
sContentType = flds("urn:schemas:mailheader:content-type")
set stm = Flds(adDefaultStream).Value
If Not sContentType = "" And InStr(sContentType, "text") > -1 Then
Stm.Type = adTypeText
If InStr(sContentType,"charset=") > -1 Then
Stm.Charset = Mid(sContentType, InStr(sContentType, "charset=") + 8)
End If
End If
Set getStream = Stm
End Function
</script>
</job>
该例程用ADO列出所有inbox中的邮件:
Visual Basic
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Server Library
' ..
Dim Rec As New ADODB.Record
Dim Rs As New ADODB.Recordset
Dim strURLInbox As String
strURLMailbox = "file://./backofficestorage/microsoft.com/MBX/user1/"
Rec.Open strURLMailbox
sURLInbox = Rec.Fields("urn:schemas:httpmail:inbox")
Rec.Open sURLInbox, Rec.ActiveConnection
Dim strView As String
strView = "select " _
& " ""DAV:HREF""" _
& ", ""DAV:content-class""" _
& ", ""urn:schemas:httpmail:datereceived""" _
& ", ""DAV:isfolder""" _
& ", ""DAV:getcontentlength""" _
& ", ""urn:schemas:httpmail:from""" _
& ", ""urn:schemas:httpmail:subject""" _
& ", ""urn:schemas:mailheader:importance""" _
& ", ""urn:schemas:httpmail:hasattachment""" _
& ", ""urn:schemas:httpmail:read""" _
& " from scope ('shallow traversal of """ _
& strURLInbox & """') " _
& " WHERE ""DAV:isfolder"" = false AND ""DAV:ishidden"" = false" _
& " ORDER BY ""urn:schemas:httpmail:datereceived"" DESC"
Rs.Open strView, Rec.ActiveConnection
If Rs.RecordCount = 0 Then
' no items in inbox
Else
Rs.MoveFirst
While Not Rs.EOF
' render view data here
Rs.MoveNext
Wend
End If
希望这些讯息对您有帮助。
- 微软全球技术中心 DTA技术支持
本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。
Top
3 楼xch74(koko)回复于 2002-04-17 07:55:58 得分 0
这与您提取的用途有关.Top





