public static string GetCode(IZennoPosterProjectModel project, string email, string password, bool spam_to_inbox = true){
            string imap = "imap.rambler.ru";        
            string sender = "info@";
            string[] theme = new[]{"theme 1", "thheme 2" }; // текст, который содержится в теме письма
            string[] recode = new[]{@"(?<=token=).{64}?(?="")", @"(?<=>).\d{3,10}(?=<)" }; // регулярки, которыми выстаскивал содержимое...
            string code = string.Empty;
            using (var client = new MailKit.Net.Imap.ImapClient()) {
                client.CheckCertificateRevocation = false; // здесь видимо важно
                client.ServerCertificateValidationCallback = (s,c,h,e) => true; // здесь видимо важно
                client.Connect(imap, 993, MailKit.Security.SecureSocketOptions.SslOnConnect);
                client.Authenticate(email, password);
                MailKit.IMailFolder inbox = client.Inbox;
                if(spam_to_inbox) {
                    MailKit.IMailFolder spam = client.GetFolder(MailKit.SpecialFolder.Junk);
                    spam.Open(MailKit.FolderAccess.ReadWrite);
                    var uids = spam.Search(MailKit.Search.SearchQuery.All);
                    foreach (var uid in uids) spam.MoveTo(uid, inbox);
                    spam.Close();  
                }
               
                inbox.Open(MailKit.FolderAccess.ReadWrite);
                foreach(var uid in inbox.Search(MailKit.Search.SearchQuery.All)){
                    code = string.Empty;
                    var mess = inbox.GetMessage(uid);              
                    string mess_sender = mess.From.ToArray()[0].ToString();
                    string mess_theme = mess.Subject;
                    string mess_body  =mess.HtmlBody;              
                    if(mess_sender.ToLower().Contains(sender)) {
                        project.SendInfoToLog("Отправитель подходит", true);
                        for(int j=0; j<theme.Length; j++) {
                            code = string.Empty;
                            project.SendInfoToLog("Проверяем тему", true);
                            if(mess_theme.ToLower().Trim().Contains(theme[j])){
                                project.SendInfoToLog("Тема подходит", true);
                                code =  Regex.Match(mess_body, recode[j]).Value;
                                project.SendInfoToLog(string.Format(@"{0} {1}: {1}", email, theme[j], code),true);
                                if(!string.IsNullOrEmpty(code)) {                      
                                    break;
                                }
                            }
                            else {
                                project.SendInfoToLog("Тема НЕ подходит", true);
                            }
                        }
                        if(!string.IsNullOrEmpty(code)){
                            inbox.AddFlags (uid, MessageFlags.Deleted, true);
                            inbox.Expunge();
                            break;
                        }
                    }
                    else {
                        project.SendInfoToLog("Отправитель НЕ подходит - берем следующее", true);
                    }
                }
                client.Disconnect(true);
            }
            return code;
        }