Beispiel #1
0
 public Form1()
 {
     InitializeComponent();
     CreateMyMultilineTextBox();
     DisplayData(ManageDB.DBTOLIST(con), false);
     //DisplayData(LoadApp.mail,false);
 }
Beispiel #2
0
 private void button6_Click(object sender, EventArgs e)
 {
     ListView.SelectedListViewItemCollection mails = listView1.SelectedItems;
     foreach (ListViewItem item in mails)
     {
         ManageDB.RemoveMailByRef(Int32.Parse(item.SubItems[4].Text), con);
     }
     DisplayData(ManageDB.DBTOLIST(con), false);
 }
Beispiel #3
0
        public async void Refresh()
        {
            await Task.Run(() =>
            {
                /*Refresh (count message and compare with database*/
                /*Save new mail to DB*/
                ManageDB.RemoveMail(con);
                System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
                var mails = new List <Mail>();
                MessagePart plainTextPart = null, HTMLTextPart = null;

                string pattern = @"[A-Za-z0-9]*[@]{1}[A-Za-z0-9]*[.\]{1}[A-Za-z]*";
                int a          = 0;
                foreach (var msg in Manage.Receive())
                {
                    //Check you message is not null
                    if (msg != null)
                    {
                        plainTextPart = msg.FindFirstPlainTextVersion();
                        //HTMLTextPart = msg.FindFirstHtmlVersion();
                        //mail.Html = (HTMLTextPart == null ? "" : HTMLTextPart.GetBodyAsText().Trim());
                        ManageDB.AddMailToDB(
                            new Mail
                        {
                            From       = Regex.Match(msg.Headers.From.ToString(), pattern).Value,
                            Subject    = msg.Headers.Subject,
                            Date       = msg.Headers.DateSent.ToString(),
                            msg        = (plainTextPart == null ? "" : plainTextPart.GetBodyAsText().Trim()),
                            Attachment = msg.FindAllAttachments(),
                            Reference  = a += 1
                        }, con);                                                      //if mails ! DB ajouter
                    }
                }
            });

            DisplayData(ManageDB.DBTOLIST(con), false);
        }
Beispiel #4
0
        //Lire les msg envoyés
        private void button4_Click(object sender, EventArgs e)
        {
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            var         mails = new List <Mail>();
            MessagePart plainTextPart = null, HTMLTextPart = null;

            string pattern = @"[A-Za-z0-9]*[@]{1}[A-Za-z0-9]*[.\]{1}[A-Za-z]*";

            foreach (var msg in Manage.Receive())
            {
                //Check you message is not null
                if (msg != null)
                {
                    plainTextPart = msg.FindFirstPlainTextVersion();
                    //HTMLTextPart = msg.FindFirstHtmlVersion();
                    //mail.Html = (HTMLTextPart == null ? "" : HTMLTextPart.GetBodyAsText().Trim());
                    mails.Add(new Mail {
                        From = Regex.Match(msg.Headers.From.ToString(), pattern).Value, Subject = msg.Headers.Subject, Date = msg.Headers.DateSent.ToString(), msg = (plainTextPart == null ? "" : plainTextPart.GetBodyAsText().Trim())
                    });
                }
            }
            DisplayData(ManageDB.DBTOLIST(con), true);
            //DisplayData(LoadApp.mail, true);
        }
        public async void load(int numberMail)
        {
            IProgress <int> progress = new Progress <int>(value => { progressBar1.Value = value; });

            progressBar1.Visible = true;
            progressBar1.Minimum = 0;
            progressBar1.Step    = 1;
            Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            var client = new Pop3Client();

            client.Connect("pop.gmail.com", 995, true);
            client.Authenticate("recent:[email protected]", "vnfkfkxlcgpnebra");
            List <string> uids = client.GetMessageUids();
            List <OpenPop.Mime.Message> AllMsgReceived = new List <OpenPop.Mime.Message>();
            SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Alexandre\Source\Repos\MailApplication\MailManager\DB\database1.mdf;Integrated Security=True");

            ManageDB.RemoveMail(con);

            List <string> seenUids     = new List <string>();
            int           messageCount = client.GetMessageCount();

            progressBar1.Maximum = numberMail;
            await Task.Run(() =>
            {
                firstkeer = false;
                for (int i = messageCount; i >= (messageCount - numberMail); i--)
                {
                    progress.Report(messageCount - i);
                    OpenPop.Mime.Message unseenMessage = client.GetMessage(i);
                    AllMsgReceived.Add(unseenMessage);
                }

                var mails = new List <Mail>();
                MessagePart plainTextPart = null, HTMLTextPart = null;
                string pattern            = @"[A-Za-z0-9]*[@]{1}[A-Za-z0-9]*[.\]{1}[A-Za-z]*";

                int a = 0;
                foreach (var msg in AllMsgReceived)
                {
                    //Check you message is not null
                    if (msg != null)
                    {
                        plainTextPart = msg.FindFirstPlainTextVersion();
                        //HTMLTextPart = msg.FindFirstHtmlVersion();
                        //mail.Html = (HTMLTextPart == null ? "" : HTMLTextPart.GetBodyAsText().Trim());

                        //ajouter au serveur
                        //mails.Add(new Mail { From = Regex.Match(msg.Headers.From.ToString(), pattern).Value, Subject = msg.Headers.Subject, Date = msg.Headers.DateSent.ToString(), msg = (plainTextPart == null ? "" : plainTextPart.GetBodyAsText().Trim()), Attachment = msg.FindAllAttachments() });

                        ManageDB.AddMailToDB(
                            new Mail {
                            From       = Regex.Match(msg.Headers.From.ToString(), pattern).Value,
                            Subject    = msg.Headers.Subject, Date = msg.Headers.DateSent.ToString(),
                            msg        = (plainTextPart == null ? "" : plainTextPart.GetBodyAsText().Trim()),
                            Attachment = msg.FindAllAttachments(), Reference = a += 1
                        }, con);
                    }
                }
                ManageDB.AddNewContact(con);
                //LoadApp.mail = mails;
                successLoad = true;
            });

            label1.Text = "";

            button1.Show();
        }