Displaying Contents of Inbox With ListView??

masj78

Active member
Joined
Aug 8, 2003
Messages
31
Location
Harrogate, UK
Please help someone!
I am trying to get a display of the emails in my Inbox in my application using a ListView.
I can get the first item and subitem in my Loop cycling through the Inbox. However I cannot get any more subItems to print in the remaining collumns. If I do I get this error message:


A first chance exception of type System.Reflection.AmbiguousMatchException occurred in microsoft.visualbasic.dll
Additional information: No accessible overloaded ListViewSubItemCollection.Add can be called without a narrowing conversion.


My code is as follows:

VB.NET:

Dim objMessage As MAPI.Message
Dim lstStuff As New ListViewItem
Dim count As Integer

With ListView1.Items
For Each objMessage In gobjSession.Inbox.Messages

count = count + 1
lstStuff = .Add(objMessage.Size)

With lstStuff
.SubItems.Add(objMessage.Subject)
.SubItems.Add(objMessage.TimeReceived) error if add this extra line
End With
Next

End With
End Sub

Cheers!
 
Last edited by a moderator:
I have solved this in another forum. The ListView does not allow different variable types to co-exist together. The only variable type accepted is String. The first item and subitem are both of type String. The time received subitem I was trying to add is of type Variant.
What was needed was to cast it to a String, which is of course simple; As follows:

.SubItems.Add(objMessage.TimeReceived.ToString)

Job Done!
 

Similar threads

P
Replies
0
Views
112
Paulywog0667_Laptop
P
M
Replies
0
Views
149
muhammadanzar
M
Back
Top