'------------------------------------------------------------------------- ' cdosample-pf.vbs ' ' Beschreibung: ' Beispielskript zum Zugriff auf öffentliche Ordner ' Script is running with permissions of currently logged on User ' ' (c)2006 Net at Work Netzwerksysteme GmbH '------------------------------------------------------------------------- Option Explicit Const PR_MDB_PROVIDER = &H34140102 Const pbExchangeProviderPublicGuid = "78B2FA70AFF711CD9BC800AA002FC45A" If InStr(1,WScript.FullName,"cscript",vbTextCompare) = 0 Then ' Prüfung ob mit CSCRIPT gestartet wurde WScript.echo "Bitte mit CSCRIPT aufrufen" WScript.quit (255) End If WScript.echo "CDSample-PF: gestartet" WScript.echo "CDSample-PF: Create MAPI Session" ' Connect to MAPI using Default Profile Dim oMapiSession Set oMapiSession = CreateObject("MAPI.Session") oMapiSession.Logon WScript.echo "CDSample-PF: Get Public Folder Store" ' Find Public Folder by name.even if MSDN tell, that Public Folder Infostore ' is always at position 1, thats not true (Outlook 2030 Offline etc) ' ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.WIN32COM.v10.en/cdo/html/458d7bbd-ad74-4c69-a6cd-2c4e929db6ba.htm Dim pfstore, objFolder, item For Each pfstore In oMapiSession.InfoStores If pfstore.Fields(PR_MDB_PROVIDER) = pbExchangeProviderPublicGuid Then WScript.echo "CDSample-PF: Public Folder Store found DisplayName=" & pfstore.name Exit For End If Next If Not IsEmpty(pfstore) Then WScript.echo "CDSample-PF: Get Root Folder" Set objFolder = pfstore.RootFolder ' Get named folder Dim objZielOrdner Set objZielOrdner = objFolder.folders("Alle öffentlichen Ordner").folders("NetatWork").folders("Jokes") WScript.echo "CDSample-PF: Number of Items: " & objZielOrdner.messages.count For Each item In objZielOrdner.messages WScript.echo "CDSample-PF: Items: " & item.subject Next End If WScript.echo"CDSample-PF: Logoff from Mailbox " oMapiSession.Logoff Set oMapiSession = Nothing WScript.echo"CDSample-PF: Logoff from Mailbox DONE " WScript.quit(0)