HOWTO: View Public Folder Contents from an ASP Page

Last reviewed: January 6, 1998
Article ID: Q178552
The information in this article applies to:
  • Collaboration Data Objects (CDO), version 1.2

SUMMARY

This article describes how to view the contents of a Public Folder from an Active Server Page (ASP). This article contains sample code that demonstrates this technique.

MORE INFORMATION

A difference between viewing Public Folders in Visual Basic and from Visual Basic Script (VBScript) in an ASP page, is that in VBScript you need to use the GetFolder() method, which necessitates knowing the FolderID. If you do not know the FolderID, you need to determine the FolderID programmatically.

The following code looks for the "*Welcome to Public Folders*" folder in the "Public Folders" collection. Insert the following code into an ASP file and make appropriate modifications for server, mailbox, and folders:

   <%@ LANGUAGE="VBSCRIPT" %>

   <HTML>
   <HEAD>
   <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
   <META HTTP-EQUIV="Content-Type" content="text/html;charset=iso-8859-1">
   <TITLE>Document Title</TITLE>
   </HEAD>
   <BODY>

   <!-- Insert HTML here -->
   <%
   CONST strServer      = "MyServer"
   CONST strMailbox     = "MyMailbox"
   Dim objSession
   Dim objMessages
   Dim objOneMessage
   Dim objInfoStores
   Dim objInfoStore
   Dim objTopFolder
   Dim objFolders
   Dim objSubFolder
   Dim objTargetFolder
   Dim strProfileInfo
   Dim i
   Dim bstrPublicRootID

   strProfileInfo = strServer & vblf & strMailbox
   Set objSession = Server.CreateObject("MAPI.Session")
   objSession.Logon , , , False, , True, strProfileInfo
   Set objInfoStores = objSession.InfoStores

   For i = 1 To objInfoStores.Count
    If objInfoStores.Item(i)= "Public Folders" Then
       Set objInfoStore=objInfoStores.Item(i)
       Exit For
    End If
   Next

   bstrPublicRootID = objInfoStore.Fields.Item( &H66310102 ).Value
   Set objTopFolder = objSession.GetFolder(bstrPublicRootID, _
               objInfoStore.ID)
   Set objFolders = objTopFolder.Folders
   Set objFolder = objFolders.GetFirst()

   Do Until objFolder.Name = "*Welcome to Public Folders*"
    Set objFolder=objFolders.GetNext()
   Loop

   Set objMessages = objFolder.Messages
   Response.Write("10 objMessages.Count = " & objMessages.Count _
         & "<br>")
   For Each objOneMessage in objMessages
     Response.Write("objOneMessage.Subject = " & _
            objOneMessage.Subject & "<br>")
     Response.Write("objOneMessage.Text = " & objOneMessage.Text & _
           "<br> <br>")
   Next

   objSession.Logoff
   Set objOneMessage = Nothing
   Set objMessages = Nothing
   Set objFolder = Nothing
   Set objTopFolder = Nothing
   Set objSession = Nothing
   %>
   </BODY>
   </HTML>

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

Keywords          : kbcode cdo kbInetDev vbsMisc
Version           : WINDOWS:1.2
Platform          : WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.