In VB 6...this works...but not with VB.NET Any Ideas? 
Author Message
 In VB 6...this works...but not with VB.NET Any Ideas?

The Problem is with the "If objMessage Is Nothing Then" Statement.

Code:

Dim objSession As MAPI.Session

Dim objFolder As MAPI.Folder

Dim objMessages As MAPI.Messages

Dim objMessage As Message

objSession = CreateObject("MAPI.Session")

objSession.Logon()

objFolder = objSession.Inbox

objMessages = objFolder.Messages

MsgBox(objMessages.Count)

objMessage = objMessages.GetFirst()

If objMessage Is Nothing Then

MsgBox("Folder is empty.")

End If



Tue, 08 Feb 2005 01:20:49 GMT  
 In VB 6...this works...but not with VB.NET Any Ideas?
Can you tell us which MAPI library you are using?
We tried msmapi.ocx in system32 but this appears to not be the same library
you are coding against.
Dave & Yu-Fang
VB.NET Development

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> The Problem is with the "If objMessage Is Nothing Then" Statement.

> Code:

> Dim objSession As MAPI.Session

> Dim objFolder As MAPI.Folder

> Dim objMessages As MAPI.Messages

> Dim objMessage As Message

> objSession = CreateObject("MAPI.Session")

> objSession.Logon()

> objFolder = objSession.Inbox

> objMessages = objFolder.Messages

> MsgBox(objMessages.Count)

> objMessage = objMessages.GetFirst()

> If objMessage Is Nothing Then

> MsgBox("Folder is empty.")

> End If



Tue, 08 Feb 2005 03:30:56 GMT  
 In VB 6...this works...but not with VB.NET Any Ideas?
Il cervello cattivo di Dan Phillips produceva il seguente:

Quote:

> The Problem is with the "If objMessage Is Nothing Then" Statement.

> Code:

> Dim objSession As MAPI.Session
> Dim objFolder As MAPI.Folder
> Dim objMessages As MAPI.Messages
> Dim objMessage As Message
> objSession = CreateObject("MAPI.Session")
> objSession.Logon()
> objFolder = objSession.Inbox
> objMessages = objFolder.Messages
> MsgBox(objMessages.Count)
> objMessage = objMessages.GetFirst()
> If objMessage Is Nothing Then
> MsgBox("Folder is empty.")
> End If

How about replacing it with:

If objMessages.Count = 0 Then
    MsgBox("Folder is empty.")
End If

--
Tenchi (remove 'spam.be.gone' for emails)

My VB.net Download-Manager (Version 1.12.1400)
Homepage: http://home.arcor.de/minako.aino/DownloadWonder/
Mailing list: http://de.groups.yahoo.com/group/dw-net/



Tue, 08 Feb 2005 05:55:03 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. SetDataSource not working with Crystal Reports .NET in VB.NET

2. Eventhandler for an addin created in vb.net for Outlook 2002 not working

3. vb .net validating event does not work properly

4. Help: ActiveX control works in VB6 but not in VB.Net

5. Timer property not working in VB.Net standard

6. Same Code which Works in C# and not in VB.NET

7. Printing from VB.Net application - Font not working

8. e.Handled=True Does Not Work For ComboBox In VB.Net

9. CreateFile does not work in VB.NET?!!!

10. Win API Call not working in vb.net app distributed to WIn 98

11. VB.NET help files not working

12. Set properties code not working in VB .NET

 

 
Powered by phpBB® Forum Software