//public task() { }
        public void GetAndSend()
        {
            bool cond = false;


            var hs        = new DownloadNodesSample.HtmlSample(url);
            var file_link = hs.Find(word);

            if (file_link == "")
            {
                MessageBox.Show("Nie znaleziono takiego obrazka");
                cond = false;
            }
            else
            {
                cond = true;

                using (WebClient client = new WebClient())
                {
                    client.DownloadFile(new Uri(file_link), image);
                }
            }


            if (cond == true)
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(email);
                mail.Subject = "Nowy obrazek";
                mail.Body    = "Nowy obrazek w załączniku";
                mail.Attachments.Add(new Attachment(image));

                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "dotnet44");
                SmtpServer.EnableSsl   = true;

                SmtpServer.Send(mail);


                MessageBox.Show("Prawdopodobnie wysłano :)");
            }
        }
Exemple #2
0
        public override void initialize()
        {
            var site  = new DownloadNodesSample.HtmlSample("http://" + Site);
            var image = site.FindImage(Keyword);

            if (image != null && image != "BRAK SZUKANEGO OBRAZKA")
            {
                string body = "<html><body><br/><br/><img src=" + image +
                              " /></body></html></body></html>";
                string subject = "Twój obrazek z " + Site;
                if (this.emailAdress != null)
                {
                    var email = new Email(emailAdress, subject, body);
                    email.SendEmail();
                }
                else
                {
                    var window = new PopOut(image, subject);
                    window.initialize();
                }
            }
        }