2

I'm facing a problem. I am able to read messages on my VB.net app using OpenPop, but I'd like to list only unread messages due the long time I should wait to list them all. Here is the documentation in C# and here is what I tried, although something's wrong:

Dim list As New List(Of Message)
Public Function FetchUnseenMessages(ByVal hostname As String, ByVal port As Integer, useSsl As Boolean, ByVal username As String, ByVal password As String, ByVal seenUids() As String)
    Using client = New Pop3Client
        client.Connect("pop.mail.yahoo.com", "995", True)
        client.Authenticate("xxxxxxx@yahoo.com", "xxxxxxx")
        Dim uids As List(Of String) = client.GetMessageUids()
        Dim newMessages As List(Of Message) = New List(Of Message)
        For i As Integer = 0 To uids.Count Step 1
            Dim currentUidOnServer As String = uids(i)
            If Not seenUids.Contains(currentUidOnServer) Then

                Dim unseenMessage As Message = client.GetMessage(i + 1) ' error here
                newMessages.Add(unseenMessage)

            End If
        Next
    End Using
End Function

I'm getting error whin trying to declare unseenMessage as message and assign its value with client.getmessage(i+1).

laylarenee
  • 3,276
  • 7
  • 32
  • 40

1 Answers1

0

The problem here seems to be that the type of unseenMessage is not OpenPop.Mime.Message, but rather some other type. If you explicitly state the fully qualified namespace & type, as shown below, this will fix the type conversion error:

Dim unseenMessage As OpenPop.Mime.Message = client.GetMessage(i + 1)

It seems that you might have unintentionally Imported another namespace which contains a Message Class, such as:

Imports System.ServiceModel.Channels
Imports System.Web.Services.Description
laylarenee
  • 3,276
  • 7
  • 32
  • 40