I'm using open source component to retrieve emails from my mail server using vb.net (pop3) but because i have a lot of messages it gives me response Time out and i think if i just got the new messages it will make reading faster. this is my code:
    Dim popp As New Pop3Client("[email protected]", "*******", "pop3.mail.com")
    popp.AuthenticateMode = Pop3AuthenticateMode.Pop
    popp.Port = 110
    'popp.Ssl = True
    popp.Authenticate()
    Dim msglist As New List(Of String)
    If popp.State = Pop3ConnectionState.Authenticated Then
        Dim totalmsgs As Integer = popp.GetTotalMessageCount()
        If totalmsgs > 0 Then
            For index As Integer = 1 To totalmsgs
                Dim msg As Pop3Message = popp.GetMessage(index)
                msglist.Add(msg.Subject)
            Next
            popp.Close()
        End If
    End If
    Return msglist
please i need some help if i'm using the component in a wrong way or if there is another component do what i'm looking for. b.s. : my component name is "Higuchi.Mail.dll" or "OpenPOP.dll" and the two are same.
thanks
POP3 does not have the capibility to track whether messages are read or unread. I would suggest you set your limit to a finite number such as 50 or 100. Perhaps you could do some sort of pagination system.
This code needs to be within a function so that you can call it like so:
Sub Main
    Dim start As Integer = Integer.parse(Request.QueryString("start"))
    Dim count As Integer = Integer.parse(Request.QueryString("count"))
    Dim subjects As New List(Of String)
    subjects = getSubjects(start, count)
    'Do whatever with the results...
    '
End Sub
Function getSubjects(ByVal startItem As Integer, ByVal endItem as Integer) As List(Of String)
   Dim popp As New Pop3Client("[email protected]", "*******", "pop3.mail.com")
    popp.AuthenticateMode = Pop3AuthenticateMode.Pop
    popp.Port = 110
    popp.Authenticate()
    Dim msglist As New List(Of String)
    If popp.State = Pop3ConnectionState.Authenticated Then
        Dim totalmsgs As Integer = popp.GetTotalMessageCount()
        Dim endItem As Integer = countItems + startItem
        If endItem > totalmsgs Then
            endItem = totalmsgs
        End If
        If totalmsgs > 0 Then
            For index As Integer = startItem To endItem
                Dim msg As Pop3Message = popp.GetMessage(index)
                msglist.Add(msg.Subject)
            Next
            popp.Close()
        End If
    End If
    Return msglist
End Function
Just have the program change the value for startItem to 50 get the next fifty (items 50-100)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With