Saeideh Hemmati
Saeideh Hemmati

Reputation: 25

unable to get Yahoo mail by Message-ID using mailkit

I want to fetch mail item by Message-Id using following code.

     var messageId = messageIdStringValue.DecryptFromBase64();
          var newId = "<" + messageId + ">";
        var matches = Client.Inbox.Search(SearchQuery.HeaderContains("Message-ID", newId));
        foreach (var uid in matches)
        {

            var message = Client.Inbox.GetMessage(uid);

        }

It's working fine with Gmail by there is no result for Yahoo mail.I should mention that I can get All mail items but the problem is in fetching the single message.Am I doing something wrong?

Upvotes: 0

Views: 559

Answers (2)

Saeideh Hemmati
Saeideh Hemmati

Reputation: 25

Thanks to @jstedfast I've found that the best way for searching mail item is by UniqueId not by the Message-ID as the search command maybe return no result in that way for different servers. following code works fine for all servers:

 foreach (var item in Client.Inbox.Fetch(new[] { uId }, MessageSummaryItems.UniqueId | MessageSummaryItems.BodyStructure))
        {
          var message = Client.Inbox.GetMessage(item.UniqueId)
        }  

Upvotes: 1

jstedfast
jstedfast

Reputation: 38528

Different IMAP servers implement SEARCH differently.

That said, why are you base64 decoding the message-id value? That doesn't make sense.

Upvotes: 0

Related Questions