diff --git a/README.md b/README.md index fb9fdaf..5b1e4c1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Receiving emails with MailKitSimplified.Receiver is as easy as: ```csharp using var imapReceiver = ImapReceiver.Create("localhost"); -var mimeMessages = await imapReceiver.ReadMail.GetMimeMessagesAsync(); +var mimeMessages = await imapReceiver.ReadMail.Top(1).GetMimeMessagesAsync(); ``` You can even monitor an email folder for new messages asynchronously, never before has it been this easy! @@ -29,7 +29,7 @@ await imapReceiver.MonitorFolder.OnMessageArrival(m => Console.WriteLine(m.Uniqu Once you've got either a mime message or a message summary, replying is now equally as intuitive. ```csharp -var mimeReply = mimeMessages.GetReplyMessage("

Reply here.

"); +var mimeReply = mimeMessage.GetReplyMessage("

Reply here.

").From("noreply@example.com"); ``` You're welcome. 🥲 @@ -69,6 +69,8 @@ var mimeMessages = await imapReceiver.ReadMail .GetMimeMessagesAsync(cancellationToken); ``` +Note: Use imapReceiver.ReadMail.Top(#) to get the newest (descending) results. + To only download the email parts you want to use: ```csharp @@ -76,6 +78,8 @@ var messageSummaries = await imapReceiver.ReadMail .GetMessageSummariesAsync(cancellationToken); ``` +Note: MailKit returns results in ascending order by default, use messageSummaries.Reverse() to get descending results. + To query unread emails from the IMAP server and specify which message parts to download: ```csharp diff --git a/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs b/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs index e96dea7..98d1747 100644 --- a/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs +++ b/source/MailKitSimplified.Receiver/Services/MailFolderReader.cs @@ -318,8 +318,10 @@ public async Task> GetMimeMessagesAsync(CancellationToken can } else if ((_take == _all && !_top.HasValue) || _searchQuery != _queryAll) { - if (_take > _queryAmount) - _logger.LogWarning($"Take({_take}) limited by SearchQuery to 250 results."); + if (_take != _all && (uint)_skip + _take > _queryAmount) + _logger.LogWarning($"Skip({_skip}).Take({_take}) limited by SearchQuery to 250 results."); + else if (_take == _all) + _logger.LogDebug("GetMimeMessagesAsync() limited by SearchQuery to 250 results."); var uniqueIds = await mailFolder.SearchAsync(_searchQuery, cancellationToken).ConfigureAwait(false); var descendingUids = new UniqueIdSet(uniqueIds, SortOrder.Descending).Skip(_skip); var filteredUids = _take == _all ? descendingUids : descendingUids.Take(_take);