2017-03-06 72 views
0

我使用AE.Net.Mail從Gmail帳戶中獲取電子郵件,目前爲止這麼好。 我的一個要求是在我的流程結束時放置一個特殊的gmail標誌。使用c#的IMAP - AE.Net.Mail設置Gmail標誌

你可以看到星星是如何工作的:http://fieldguide.gizmodo.com/add-extra-stars-for-better-gmail-sorting-1681334535

這裏是我的代碼:

//Get msgs. 
Messages = imap.SearchMessages(condition2); 

foreach (Lazy<AE.Net.Mail.MailMessage> message in this.Messages) 
{ 
    imap.AddFlags("Seen", message.Value); 
    imap.AddFlags("\\Seen", message.Value); 
    imap.AddFlags("\\Flagged", message.Value); 
    imap.AddFlags("green-check", message.Value); 

我期待有標有綠色檢查明星的電子郵件,直到這一點上,郵件標有黃色星號(標記),我錯過了什麼?

非常感謝您的幫助。

回答

1

您很可能無法將其設置爲IMAP標誌。很可能你需要使用GMail的LABELS擴展,這可能不被AE.Net.Mail支持。

但是,您可以使用我的MailKit庫來操作GMail上的標籤。

http://www.mimekit.net/docs/html/Overload_MailKit_MailFolder_AddLabels.htm http://www.mimekit.net/docs/html/Overload_MailKit_MailFolder_RemoveLabels.htm http://www.mimekit.net/docs/html/Overload_MailKit_MailFolder_SetLabels.htm

請求對批量信息的標籤,你可以這樣做:

var items = folder.Fetch (uids, MessageSummaryItems.UniqueId | MessageSummaryItems.GMailLabels); 
foreach (var item in items) { 
    Console.WriteLine ("message {0} has the following labels: {1}", item.UniqueId, 
     item.GMailLabels != null ? string.Join (", ", item.GMailLabels) : "None"); 
}