Esempio n. 1
0
        private void btnMesajOku_Click(object sender, EventArgs e)
        {
            try
            {
                MailRepository rep = new MailRepository();
                if (cmbServerMesajOku.SelectedIndex == 0)
                {
                    rep.Connect("pop.gmail.com", txtEmail.Text, txtSifre.Text, 995, true);
                }
                else
                {
                    rep.Connect("Outlook.office365.com", txtEmail.Text, txtSifre.Text, 995, true);
                }



                foreach (var item in rep.GetMail())
                {
                    string[] body = item.Message.MessagePart.GetBodyAsText().Split('>');
                    rtxtMesajlar.AppendText("\nFrom: " + item.Message.Headers.From.Address + "\n" + "Subject: "
                                            + item.Message.Headers.Subject + "\n" + "TEXT: " + body[1]);
                }
            }
            catch
            {
                MessageBox.Show("Lütfen Girdiğiniz Bilgilerin Doğruluğunu Kontrol Edin", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public IActionResult ImportList(EmailSettings model)
        {
            var client = new MailRepository();

            client.Connect(hostname: "imap.gmail.com", username: "******", password: "******", port: 995, isUseSsl: true);
            //client.Connect(hostname: "imap.gmail.com", username: "******", password: "******", port: 995, isUseSsl: true);

            //client.Connect(hostname: model.Host, username: model.UserName, password: model.Password, port: 995, isUseSsl: true);
            var allMail   = client.GetMail();
            var emailList = new List <EmailMessage>();

            foreach (var mail in allMail)
            {
                var email   = new EmailMessage();
                var subject = mail.Message.Headers.Subject;
                var to      = string.Join(",", mail.Message.Headers.To.Select(m => m.Address));
                var from    = mail.Message.Headers.From.Address;

                Console.WriteLine("Email Subject: {0}", subject);
                Console.WriteLine("Sent To: {0}", to);
                Console.WriteLine("Sent From: {0}", from);
                email.From    = from;
                email.Subject = subject;
                email.Body    = mail.Message.ToMailMessage().Body;
                var attachments = client.GetAttachments(mail.Message);

                if (attachments.Any())
                {
                    // foreach (var attachment in attachments)
                    // {

                    // Console.WriteLine("File Location: {0}", attachment);
                    //}
                    email.CV = string.Join(',', attachments);
                }
                else
                {
                    Console.WriteLine("Email has no attachments, if attachments are required, make sure to not delete this email");
                }
                //  var mailWithAttachments = client.GetMail(fromAddress:from);

                //foreach (var mailwithAtt in mailWithAttachments)
                //{

                //    client.Delete(mailwithAtt.MessageNumber);
                //}
                // client.Delete(mail.MessageNumber);
                emailList.Add(email);
            }
            return(View(emailList));
        }
Esempio n. 3
0
        private void btnMesajOku_Click(object sender, EventArgs e)
        {
            MailRepository rep = new MailRepository();

            rep.Connect("outlook.office365.com", txtEmail.Text, txtSifre.Text, 995, true);



            foreach (var item in rep.GetMail())
            {
                string[] body = item.Message.MessagePart.GetBodyAsText().Split('>');
                rtxtMesajlar.AppendText("\nFrom: " + item.Message.Headers.From.Address + "\n" + "Subject: "
                                        + item.Message.Headers.Subject + "\n" + "TEXT: " + body[1]);
            }
        }