[英]Mailkit error No uids were specified. Parameter name: uids
我想像這樣在收件箱中獲取所有消息:
using (ImapClient client = new ImapClient(new ProtocolLogger("/imap.log", append: true)))
{
client.Timeout = 1200000;
if (!client.IsConnected)
client.Connect(imap.testserver.com, testportnumber, true);
client.Authenticate(email, lockmail);
var searchcond = SearchQuery.All;
var Inbox = client.Inbox;
Inbox.Open(MailKit.FolderAccess.ReadOnly);
var inbox = Inbox.Search(searchcond);
var fetchs = Inbox.Fetch(inbox, MessageSummaryItems.Envelope | MessageSummaryItems.Flags);
}
在提取行上,發生此錯誤:未指定uid。 參數名稱:uids
這是否意味着Inbox.Search返回郵件文件夾中不存在的一些Uid?
我該如何解決?
這意味着Search()
返回了0個UID。
您可以通過執行以下操作來避免此問題:
var uids = inbox.Search (query);
if (uids.Count > 0) {
var messages = inbox.Fetch (uids, ...);
...
}
如果您使用的MailKit早於2.0.7,則可以嘗試升級到2.0.7,這應該不會造成問題(例如, Fetch()
方法不應處理一組空的uid並返回w / o錯誤) 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.