我正在使用开源组件使用 vb.net (pop3) 从我的邮件服务器检索电子邮件
但因为我有很多消息,它给了我响应超时,我想如果我刚刚收到新消息,它会让阅读速度更快。
这是我的代码:
Dim popp As New Pop3Client("[email protected] /cdn-cgi/l/email-protection", "*******", "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
如果我以错误的方式使用该组件,或者如果有另一个组件执行我正在寻找的操作,请我需要一些帮助。
废话。 :我的组件名称是“Higuchi.Mail.dll”或“OpenPOP.dll”,两者是相同的。
thanks
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] /cdn-cgi/l/email-protection", "*******", "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)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)