我面临一个问题。我可以使用 OpenPop 在我的 VB.net 应用程序上阅读消息,但我想只列出未读消息,因为我应该等待很长时间才能将它们全部列出。这是 C# 中的文档,这是我尝试过的,尽管有问题:
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
尝试声明unseenMessage
为消息并使用 client.getmessage(i+1) 分配其值时出现错误。