我正在使用 mailkit 從基于 uid (IMAP) 的收件箱中讀取電子郵件,這作業正常。但是,我沒有找到以編程方式使用 mailkit 將類別設定為電子郵件的選項。
我確實看到了使用以下代碼設定自定義標志的選項。然而,這似乎不起作用,因為我們無法可視化電子郵件的狀態。
var customFlags = new HashSet<string>();
customFlags.Add("$Testing");
inbox.AddFlags(UniqueId.Parse(uid), MessageFlags.None, customFlags, true);
我正在尋找有關如何僅使用 mailkit 將以下類別設定為電子郵件的資訊。
客戶:Imap,郵箱:O365

uj5u.com熱心網友回復:
IMAP 沒有類別或樣式的概念。
這取決于用戶的郵件客戶端通過在訊息上設定自定義標志(假設 IMAP 服務器支持自定義標志)或僅以某種方式在用戶的桌面(或移動設備)本地存盤這些屬性來進行合成。
uj5u.com熱心網友回復:
正如 Jazb 所說,IMAP 沒有“類別”的概念,客戶端可以找到存盤此狀態的替代方法。
我不確定 Office365 是否支持存盤自定義關鍵字(也稱為自定義標志),但您可以做的是創建一個測驗檔案夾,并在該檔案夾中添加 6 條訊息,每個類別 1 條,為它們提供易于提示您的主題您將它們分配到哪個類別中(例如“主題:藍色類別”)。
然后使用MailKit來獲取MessageSummaryItems.Flags | MessageSummaryItems.Envelope資料:
var items = folder.Fetch (0, -1, MessageSummaryItems.Flags | MessageSummaryItems.Envelope);
foreach (var item in items) {
Console.WriteLine ("Office365 uses the {0} keyword to designate the {1}", item.Keywords.FirstOrDefault (), item.Envelope.Subject);
}
你會得到這樣的輸出:
Office365 uses the $MailLabel1 keyword to designate the Blue category
Office365 uses the $MailLabel2 keyword to designate the Green category
Office365 uses the $MailLabel3 keyword to designate the Orange category
Office365 uses the $MailLabel4 keyword to designate the Purple category
Office365 uses the $MailLabel5 keyword to designate the Red category
Office365 uses the $MailLabel6 keyword to designate the Yellow category
一旦您知道關鍵字的真實名稱(可能是也可能不是“$MailLabel1”),您就可以通過以下方式設定關鍵字:
var keywords = new HashSet<string> () { "$MailLabel1" };
folder.AddFlags (uid, MessageFlags.None, keywords, true);
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/348071.html
