Exemplo n.º 1
0
        private void receiveMail_Click(object sender, EventArgs e)
        {
            DefaultConnection connection = new DefaultConnection();

            Pop3Client client = Pop3Util.Connect();

            List <OpenPop.Mime.Message> mails = Pop3Util.FetchUnseenMessages(client, connection.ReceivedMails.Select(r => r.Uid.ToString()).ToList());

            ReceivedMail receivedMail;

            for (int i = 0; i < mails.Count; i++)
            {
                receivedMail             = new ReceivedMail();
                receivedMail.MessageId   = mails[i].Headers.MessageId;
                receivedMail.Uid         = client.GetMessageUid(i + 1);
                receivedMail.CreatedDate = DateTime.Now;
                receivedMail.ReceiveDate = mails[i].Headers.DateSent;
                receivedMail.SendBy      = mails[i].Headers.From.MailAddress.Address;
                receivedMail.Title       = mails[i].Headers.Subject;
                receivedMail.Body        = mails[i].FindFirstPlainTextVersion() != null ? mails[i].FindFirstPlainTextVersion().GetBodyAsText() : "";
                receivedMail.Status      = 0;

                var ccList       = mails[i].Headers.Cc;
                var ccListString = "";
                for (int j = 0; j < ccList.Count; j++)
                {
                    if (ccList[j].HasValidMailAddress)
                    {
                        ccListString += ccList[j].Address;
                    }

                    if (j != ccList.Count - 1)
                    {
                        ccListString += ";";
                    }
                }
                receivedMail.Cc = ccListString;

                connection.ReceivedMails.Add(receivedMail);
                receivedMail = null;
            }
            connection.SaveChanges();

            Pop3Util.Disconnect(client);
        }
Exemplo n.º 2
0
 private void button7_Click(object sender, EventArgs e)
 {
     List <OpenPop.Mime.Message> unseenMessages = Pop3Util.FetchUnseenMessages("abc.abc.com", 110, false, "*****@*****.**", "abc", new List <string> {
         "1234567890"
     });
 }