BitrixAQA.General.Pop.GetAttachmentMsg C# (CSharp) Method

GetAttachmentMsg() public static method

Проверка, содержит ли письмо вложение
public static GetAttachmentMsg ( string hostname, int port, bool useSsl, string userEmail, string Password, string Subject, string AttachmentName ) : bool
hostname string Сервер
port int Порт
useSsl bool Исользовать ли SSL
userEmail string Логин
Password string Пароль
Subject string Тема письма
AttachmentName string Имя вложения
return bool
        public static bool GetAttachmentMsg(string hostname, int port, bool useSsl, string userEmail, string Password, string Subject, string AttachmentName)
        {
            try
            {
                using (Pop3Client client = new Pop3Client())
                {

                    client.Connect(hostname, port, useSsl);
                    client.Authenticate(userEmail, Password);

                    int messageCount = client.GetMessageCount();
                    List<OpenPop.Mime.Message> allMessages = new List<OpenPop.Mime.Message>(messageCount);

                    Regex rgx = new Regex(Subject, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant);

                    for (int i = 1; i <= messageCount; i++)
                    {
                        Match match = rgx.Match(client.GetMessage(i).Headers.Subject);
                        //проверяем тему письма, если та что нам надо,ищем вложение
                        if (match.Success)
                        {
                            foreach (MessagePart Attachment in client.GetMessage(i).FindAllAttachments())
                                if (Attachment.FileName == AttachmentName.Split('\\')[AttachmentName.Split('\\').Length - 1])
                                    return true;
                        }
                    }
                    return false;
                }
            }
            catch (Exception ex)
            {
                Log.MesQuestion("Скорее всего превышено количество запросов");
                Log.MesQuestion(ex.Message);
                return false;
            }
        }

Same methods

Pop::GetAttachmentMsg ( string hostname, int port, bool useSsl, string userEmail, string Password, string Subject, int AttachmentIndex ) : string