public void PlayEmailAutomation(IMailClient client, string username, string password, bool isProtocolImap, string mailbox)
        {
            string retValue = string.Empty;
            int countMail = 0;

            retValue = client.LogIn(username, password);

            if (string.IsNullOrEmpty(retValue))
            {
                retValue = client.GetTotalMail(out countMail, mailbox);

                if (string.IsNullOrEmpty(retValue))
                {
                    if (countMail > 0)
                    {
                        var _messagesIndexs = GetMailIndex(client, mailbox); //: GetPopMailIndex(countMail);

                        _messagesIndexs = (from p in _messagesIndexs
                                           orderby p descending
                                           select p).ToList();

                        PerformAction(client, _messagesIndexs);
                    }
                    else
                    {
                        client.LogOut();
                        ((IDisposable)client).Dispose();
                    }
                }
            }

            if (!string.IsNullOrEmpty(retValue))
            {
                throw new Exception(retValue);
            }
        }
Exemple #2
0
        public void PlayEmailAutomation(IMailClient client, string username, string password, string searchCriteria, string mailbox)
        {
            string retValue  = string.Empty;
            int    countMail = 0;

            retValue = client.LogIn(username, password);

            if (string.IsNullOrEmpty(retValue))
            {
                retValue = client.GetTotalMail(out countMail, mailbox);

                if (string.IsNullOrEmpty(retValue))
                {
                    if (countMail > 0)
                    {
                        var _messagesIndexs = GetMailIndex(client, searchCriteria, mailbox);

                        _messagesIndexs = (from p in _messagesIndexs
                                           orderby p descending
                                           select p).ToList();

                        PerformAction(client, _messagesIndexs, mailbox);
                    }
                    else
                    {
                        client.LogOut();
                        ((IDisposable)client).Dispose();
                    }
                }
            }

            if (!string.IsNullOrEmpty(retValue))
            {
                throw new Exception(retValue);
            }
        }