Quantcast
Channel: ImapX 2
Viewing all articles
Browse latest Browse all 1952

New Post: Message unique identification?

$
0
0
So, here the promised example:
' Initializing the client
Dim client = New ImapClient("imap.gmail.com", True)

' Configuring the client to only download the headers
client.Behavior.MessageFetchMode = MessageFetchMode.Headers

' Setting the headers to be fetched (only Message-Id)
client.Behavior.RequestedHeaders = New String() {MessageHeader.MessageId}

If client.Connect() Then

    If client.Login("name@gmail.com", "password") Then

        ' Requesting messages
        Dim messages = client.Folders.Inbox.Search()

        ' .. Filter the messages by Message.MessageId
        Dim filteredMessages = messages.Where(Function(msg As Message)
                                                  Return msg.MessageId = "Sample-Message-Id"
                                              End Function)

        ' After you filtered the messages, reset the requested headers by
        client.Behavior.RequestedHeaders = Nothing

        ' Or client.Behavior.RequestedHeaders = MessageHeaderSets.Minimal;

        For Each message As Message In filteredMessages

            ' Download the messages with another fetch mode. 
            ' The second parameter indicates that the headers should be requested one more time
            message.Download(MessageFetchMode.Basic, True)

        Next

    End If

End If
If you have more questions, feel free to ask.

Best regards,

Pavel

Viewing all articles
Browse latest Browse all 1952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>