如何正确设置日期范围(到分钟、秒)以接收来自电子邮件的信件
How to set the date range correctly (to the minute, seconds) in order to receive letters from the email
Imports EAGetMail
Public Sub ReceiveMail( _
ByVal sServer As String, _
ByVal sUserName As String, _
ByVal sPassword As String, _
ByVal bSSLConnection As Boolean _
)
Dim oClient As New MailClient("TryIt")
Dim oServer As New MailServer(sServer, _
sUserName, sPassword, bSSLConnection, _
ServerAuthType.AuthLogin, ServerProtocol.Imap4)
Try
oClient.Connect(oServer)
Dim options As GetMailInfosOptionType = GetMailInfosOptionType.ReadOnly
options = options Or GetMailInfosOptionType.DateRange
options = options Or GetMailInfosOptionType.OrderByDateTime
oClient.GetMailInfosParam.Reset()
oClient.GetMailInfosParam.GetMailInfosOptions = options
oClient.GetMailInfosParam.SubjectContains = "test"
oClient.GetMailInfosParam.SenderContains = "support"
oClient.GetMailInfosParam.DateRange.SINCE = System.DateTime.Now.AddMonths(-12)
oClient.GetMailInfosParam.DateRange.BEFORE = System.DateTime.Now.AddDays(1)
Dim infos() As MailInfo = oClient.GetMailInfos()
...
IMAP 搜索不支持指定时间、句点。如果您想比当天更精确地缩小范围,则必须获取元数据并在客户端进行。
解决方案:您可以使用搜索来获取所需日期的消息 ID(请注意 IMAP 也不是真正的 TZ 感知,因此您可能需要额外获取一天),然后获取它们的 INTERNALDATE,并在客户端进行精细过滤,是的。 – 最大
Imports EAGetMail
Public Sub ReceiveMail( _
ByVal sServer As String, _
ByVal sUserName As String, _
ByVal sPassword As String, _
ByVal bSSLConnection As Boolean _
)
Dim oClient As New MailClient("TryIt")
Dim oServer As New MailServer(sServer, _
sUserName, sPassword, bSSLConnection, _
ServerAuthType.AuthLogin, ServerProtocol.Imap4)
Try
oClient.Connect(oServer)
Dim options As GetMailInfosOptionType = GetMailInfosOptionType.ReadOnly
options = options Or GetMailInfosOptionType.DateRange
options = options Or GetMailInfosOptionType.OrderByDateTime
oClient.GetMailInfosParam.Reset()
oClient.GetMailInfosParam.GetMailInfosOptions = options
oClient.GetMailInfosParam.SubjectContains = "test"
oClient.GetMailInfosParam.SenderContains = "support"
oClient.GetMailInfosParam.DateRange.SINCE = System.DateTime.Now.AddMonths(-12)
oClient.GetMailInfosParam.DateRange.BEFORE = System.DateTime.Now.AddDays(1)
Dim infos() As MailInfo = oClient.GetMailInfos()
...
IMAP 搜索不支持指定时间、句点。如果您想比当天更精确地缩小范围,则必须获取元数据并在客户端进行。
解决方案:您可以使用搜索来获取所需日期的消息 ID(请注意 IMAP 也不是真正的 TZ 感知,因此您可能需要额外获取一天),然后获取它们的 INTERNALDATE,并在客户端进行精细过滤,是的。 – 最大