Пример #1
0
        public MailTransfer GetUnseenMessages(ConfigEntity configEntity, List <string> seenUids)
        {
            using (Pop3Client client = new Pop3Client())
            {
                client.Connect(configEntity.Mail, configEntity.Port, useSsl: true);
                client.Authenticate(configEntity.Login, configEntity.Password);

                var            mailTransfer = new MailTransfer();
                List <string>  uids         = client.GetMessageUids();
                List <Message> newMessages  = new List <Message>();

                for (int i = 0; i < uids.Count; i++)
                {
                    string currentUidOnServer = uids[i];
                    if (!seenUids.Contains(currentUidOnServer))
                    {
                        Message unseenMessage = client.GetMessage(i + 1);
                        newMessages.Add(unseenMessage);
                        mailTransfer.Uids.Add(currentUidOnServer);
                    }
                }

                mailTransfer.MailEntities = ConvertMassageToMailEntity(newMessages);
                return(mailTransfer);
            }
        }
Пример #2
0
        public MailTransfer GetAllMessages(ConfigEntity configEntity)
        {
            using (Pop3Client client = new Pop3Client())
            {
                client.Connect(configEntity.Mail, configEntity.Port, useSsl: true);
                client.Authenticate(configEntity.Login, configEntity.Password);

                int            messageCount       = client.GetMessageCount();
                List <Message> allMessagesOpenPop = new List <Message>(messageCount);

                var mailTransfer = new MailTransfer();

                for (int i = messageCount; i > 0; i--)
                {
                    allMessagesOpenPop.Add(client.GetMessage(i));
                    mailTransfer.Uids.Add(client.GetMessageUid(i));
                }

                mailTransfer.MailEntities = ConvertMassageToMailEntity(allMessagesOpenPop);
                return(mailTransfer);
            }
        }