如何使用 pop3 检索未读电子邮件?

发布于 2024-09-16 06:46:29 字数 991 浏览 3 评论 0原文

我正在使用开源组件使用 vb.net (pop3) 从我的邮件服务器检索电子邮件 但因为我有很多消息,它给了我响应超时,我想如果我刚刚收到新消息,它会让阅读速度更快。 这是我的代码:

    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

如果我以错误的方式使用该组件,或者如果有另一个组件执行我正在寻找的操作,请我需要一些帮助。 bs :我的组件名称是“Higuchi.Mail.dll”或“OpenPOP.dll”,两者是相同的。

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南巷近海 2024-09-23 06:46:29

POP3 无法跟踪邮件是否已读或未读。我建议您将限制设置为有限数量,例如 50 或 100。也许您可以使用某种分页系统。

此代码需要位于函数内,以便您可以像这样调用它:

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

只需让程序将 startItem 的值更改为 50 即可获得下一个 50 个项目(项目 50-100)

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)

你げ笑在眉眼 2024-09-23 06:46:29

POP3 协议没有已见/未见消息的概念。

您不能使用IMAP吗?

它将为您提供比 POP3 更多的功能(如搜索、标记、文件夹管理)。

POP3 protocol does not have the notion of seen/unseen messages.

Can't you use IMAP?

It would give you more features (like searching, flagging, folder management) than POP3.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文