0 votes

Hi,

How am I via VB filter specific dates? A range between 2 dates?
So far I have this code below but it takes for ever to loop through all e-mails and check dates.

        Dim builder As New MailBuilder()
        For Each uid As String In pop3.GetAll()

            Dim eml = pop3.GetMessageByUID(uid)
            Dim email As IMail = builder.CreateFromEml(eml)

            datum = email.[Date]
            If Year(datum) = 2018 And Month(Now) = 11 Then

Please advise, thank you SOO much!!

by

1 Answer

0 votes

POP3 protocol doesn't have any kind of searching capability.

I strongly suggest using IMAP.

You'll get searching:
https://www.limilabs.com/blog/how-to-search-imap-in-net

Pretty fast most common email fields retrieval:
https://www.limilabs.com/blog/get-email-information-from-imap-fast

If you are stuck with POP3 for some reason:
- You can use GetMessageHeadersByUID to download email headers only (no attechements and body will be downloaded) and identify messages you should download in full.
- GetAll returns messages in order, so you could probably made some guesses on the date of the messages.

by (297k points)
...