HELP: VB6 2 .NET 'Outlook.Folders' access no longer works 
Author Message
 HELP: VB6 2 .NET 'Outlook.Folders' access no longer works

Hi All,

In  my VB6 code the following GetMAPIFolderID function worked fine. When I
converted this code to .NET, the following line:

       For Each oFolder In oFolders

Generates the error:

Expression is of type 'Outlook.Folders', which is not a collection
object.

oFolders was declared as:

        Dim oFolder As Outlook.MAPIFolder
        Dim oFolders As Outlook.Folders

Does anyone know the fix for this?

Thanks
-P

--The original GetMAPIFolderID function is below: --

Function GetMAPIFolderID(ByRef sFullFolderPath As String) As
Outlook.MAPIFolder

        ' Example: sFullFolderPath = "Public Folders/All Public
Folders/Contacts"

        ' Needed objects and vars
        Dim oOLApp As Outlook.Application
        Dim oNS As Outlook.NameSpace
        Dim oFolder As Outlook.MAPIFolder
        Dim oFolders As Outlook.Folders
        Dim arrName() As String
        Dim oExplorer As Outlook.Explorer
        Dim i As Short
        Dim blnFound As Boolean

        ' Application and Namespace reference
        oOLApp = CreateObject("Outlook.Application")
        oNS = oOLApp.GetNamespace("MAPI")

        ' Build an array to get to desired folder
        'Debug.Print ("sFullFolderPath = " & sFullFolderPath)
        arrName = Split(sFullFolderPath, "/")
        'Debug.Print ("arrName = " & arrName)

        oFolders = oNS.Folders

        blnFound = False

        ' Lets walk the folder tree
        For i = 0 To UBound(arrName)
            For Each oFolder In oFolders
                'MsgBox oFolder.Name
                If oFolder.Name = arrName(i) Then
                    oFolders = oFolder.Folders
                    blnFound = True
                    Exit For
                Else
                    blnFound = False
                End If
            Next oFolder
            If blnFound = False Then
                Exit For
            End If
        Next

        If blnFound = True Then
            ' Hello Houston... I have the folder in question stored in oFolder
            GetMAPIFolderID = oFolder
            'Debug.Print "FOUND IT!"
        Else
            'UPGRADE_NOTE: Object GetMAPIFolderID may not be destroyed until it
is garbage collected. Click for more:
'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
            GetMAPIFolderID = Nothing
        End If

    End Function



Sun, 12 Sep 2004 02:37:25 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. VB6's Online Help No Longer Works

2. Changing the Outlook folder's default message class by VB6.0

3. Windows Service Calling VB6 dll doesn't work but works with VB6

4. how does VB6's API work in vb.net

5. Outlook Empy 'Deleted Items Folder'

6. fax from access dosen't work since upgrade to Outlook 2000

7. Help with API, can't get Favorite folder address in VB.NET

8. VB6's MSComm doesn't work well with Vista

9. Help - Can't disconnect Access - VB6 + Access 97 + NT4.0

10. Using folder object when the user doesn't have access to the folder

11. VB6 app running in Windows 7, can't get Help working

12. Code works when run in VB6, gets error when compiled (Browse for Outlook Folder)

 

 
Powered by phpBB® Forum Software