Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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!

Edited by masj78
Posted

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!

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...