2017-03-06 96 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"); 
}