ImapClient migration other esp mail occur mail lossed
Dylan-Jinx opened this issue · comments
J1nx commented
Describe the bug
I implement the migration mail function by Mailkit,when I calculate the mail count, I find the mail count is error, some mail lossed,but I use the other ImapClient like foxmail, it can read all mails correctly.Can you offer the method of the problem solved?
Platform (please complete the following information):
- OS: Windows11
- .NET Runtime: CoreCLR
- .NET Framework: .NetCore 8.0
- MailKit Version: 4.2.0
Exception
ImapClient can not read mail correctly
// Add your code snippet here.
private static void GetMailByFolder(IMailFolder folder)
{
folder.Open(FolderAccess.ReadOnly);
var uids = folder.Search(SearchQuery.Uids(new UniqueIdRange(UniqueId.MinValue, UniqueId.MaxValue)));
foreach (var uid in uids.OrderBy(it => it.Id))
{
var msg = folder.GetMessage(uid);
var fileStream = new FileStream($"{uid}.eml", FileMode.OpenOrCreate);
msg.WriteTo(fileStream);
}
}
Jeffrey Stedfast commented
You should use folder.Search(SearchQuery.All);
Outside of that, you don't really explain the problem. If MailKit doesn't "see" it, then it's 100% guaranteed to be a server bug.