problem upgrading cdo vb project to .net 
Author Message
 problem upgrading cdo vb project to .net

I'm trying to convert a project I'm working on involving CDO to

When working with VB6, the following works:

Dim CdoFolder As MAPI.Folder
Dim CdoMessages As MAPI.Messages
Dim CdoAppointmentItem As MAPI.AppointmentItem
--omitting MAPI session logon--
Set CdoMessages = CdoFolder.Messages
For Each CdoAppointmentItem In CdoMessages
    'do whatever

However, when I convert the above stuff to VB.NET, either by hand, or
using Visual Studio's automatic conversion from a VB6 project, the for
each line has an error claiming that "Expression is of type
'MAPI.Messages', which is not a collection type." This seems quite odd
since I can succesfully use GetFirst and GetNext methods of

Does anybody have any insight into why I can't foreach a MAPI.Messages

If CDO is no longer a recommended way to do such things, can somebody
point me in the right direction regarding the easiest approach to gain
access to MAPI sessions with


Tue, 08 Mar 2005 01:43:42 GMT  
 problem upgrading cdo vb project to .net

> Does anybody have any insight into why I can't foreach a MAPI.Messages
> object???

While I have no personal experience with CDO in .NET, I do know that using
For Each...Next syntax requires that the target of the enumeriation
implement IEnumerable and present an IEnumerator object from a call to the
IEnumerable interface's GetEnumerator function. The wrapper .NET creates for
CDO may not be doing these things, so you do not get free For Each...Next
functionality with it.

Hope this helps,


Tue, 08 Mar 2005 02:22:44 GMT  
 [ 2 post ] 

 Relevant Pages 

1. .NET VB Wizard hangs upgrading VB6 project

2. vb5 project upgrade causes exception

3. VB 6 To VB .NET OLE Upgrade Problems

4. vb6 -> upgrade problem

5. VB 6.0 project to VB.NET project ?

6. Upgrade from Visual Basic 6 webclasses to VB.NET/ASP.NET

7. debugging upgraded component in

8. Help with problem using (EIStream) OCXs in VB.NET/C# project

9. .NET project locking/loading DLL created by other .NET project

10. Problem in opening VB.Net project in Source Safe

11. Referencing a C# project within a VB.NET project

12. VB4->VB5 upgrading projects control licensing problem


Powered by phpBB® Forum Software