I am using this code to get the list of email folders :
Class emailFolder
Public Property Title As String
End Class
Public Shared Function GetFolders() As List(Of emailFolder)
Dim folder = New List(Of emailFolder)
Dim foldername = client.Folders
For Each parentFolder In foldername
Dim parentPath = parentFolder.Path
If parentFolder.HasChildren Then
Dim subfolders = parentFolder.SubFolders
For Each subfolder In subfolders
Dim subPath = subfolder.Path
folder.Add(New emailFolder With {.Title = parentFolder.Name})
Next
End If
Next
Return folder
End Function
Public sub btn_click handles Button1.click
ListView.ItemSource=GetFolders
I dunno what is wrong with my code but the items I get in the ListView
(I'm in wpf by the way) look like this :
MyApplication++emailfolder
MyApplication++emailfolder
MyApplication++emailfolder
MyApplication++emailfolder
What am I doing wrong ?
The problem was solved..Thanks for the comments guys!!
Just had to override the ToString
....Full code:
Class emailFolder
Public Property Title As String
Public Overrides Function ToString() As String
Return Me.Title
End Function
End Class
Public Shared Function GetFolders() As List(Of emailFolder)
Dim folder = New List(Of emailFolder)
Dim foldername = client.Folders
For Each parentFolder In foldername
Dim parentPath = parentFolder.Path
If parentFolder.HasChildren Then
Dim subfolders = parentFolder.SubFolders
For Each subfolder In subfolders
Dim subPath = subfolder.Path
folder.Add(New emailFolder With {.Title = parentFolder.Name})
Next
End If
Next
Return folder
End Function
Public sub btn_click handles Button1.click
ListView.ItemSource=GetFolders