private void Session_GetMessagesInfo(object sender, IMAP_e_MessagesInfo e) { if (e.Folder == "INBOX") { foreach (var message in messagesRepository.GetMessages()) { List <string> flags = new List <string>(); if (!message.IsUnread) { flags.Add("Seen"); } e.MessagesInfo.Add(new IMAP_MessageInfo(message.Id.ToString(), message.ImapUid, flags.ToArray(), message.Data.Length, message.ReceivedDate)); } } }
private void Session_GetMessagesInfo(object sender, IMAP_e_MessagesInfo e) { using (var scope = this.serviceScopeFactory.CreateScope()) { var messagesRepository = scope.ServiceProvider.GetService <IMessagesRepository>(); if (e.Folder == "INBOX") { foreach (var message in messagesRepository.GetMessages()) { List <string> flags = new List <string>(); if (!message.IsUnread) { flags.Add("Seen"); } e.MessagesInfo.Add(new IMAP_MessageInfo(message.Id.ToString(), message.ImapUid, flags.ToArray(), message.Data.Length, message.ReceivedDate)); } } } }