title: How can i make that my application will check and get specific email subject?
body: <p>I have this class that send emails. I log in using my isp email and send it to my gmail email.
  Now i want to do that when someone will download/get my application it will check each 1 minute for my gmail account address for a specific email with a specific subject so the email subject will be like a code for example the email subject will be: 16765645</p>
  
  <p>Once the application downloaded the email i want to display the email content in a textBox and also to write on a text file the email content. Also i want that the application will check the email time download after it was downloaded so the application will not download the same email all the time. </p>
  
  <p>This is how i'm sending emails today:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using DannyGeneral;
  using System.Net.Mail;
  using System.Net;
  using System.Net.Mime;
  using System.IO;
  using System.Windows.Forms;
  using System.ComponentModel;
  using System.Drawing;
  
  namespace Diagnostic_Tool_Blue_Screen
  {
      class SendEmail
      {
          private MailMessage photosmessage;
          public bool textfilessendended;
          public bool photossendended;
          Label lbl1;
          Label lbl3;
          Button SendLogFile;
          MailMessage message;
          MailMessage docmessage;
          public int timerdelay;
          public Timer timer3;
  
          public SendEmail(Label label2, Label label3, Button slf, int timerd, Timer timer)
          {
              textfilessendended = false;
              photossendended = false;
              lbl1 = label2;
              lbl3 = label3;
              SendLogFile = slf;
              timerdelay = timerd;
              timer3 = timer;
          }
  
          public void SendLogger()
          {
              string log_file_name = "logger.txt";
              string logger_file_to_read = Path.GetDirectoryName(Application.LocalUserAppDataPath) + @"\log";
              string LoggerFile = Path.Combine(logger_file_to_read, log_file_name);
              try
              {
                  MailAddress from = new MailAddress("test@gmail.com", "User " + (char)0xD8 + " Name",
                  System.Text.Encoding.UTF8);
                  MailAddress to = new MailAddress("test@test.net");
                  message = new MailMessage(from, to);
                  message.Body = "Please check the log file attachment i have some bugs.";
                  string someArrows = new string(new char[] { '\u2190', '\u2191', '\u2192', '\u2193' });
                  message.Body += Environment.NewLine + someArrows;
                  message.BodyEncoding = System.Text.Encoding.UTF8;
                  message.Subject = "Log File For Checking Bugs" + someArrows;
                  message.SubjectEncoding = System.Text.Encoding.UTF8;
                  Attachment myAttachment = new Attachment(LoggerFile, MediaTypeNames.Application.Octet);
                  message.Attachments.Add(myAttachment);
                  SmtpClient ss = new SmtpClient("smtp.gmail.com", 587);
                  ss.SendCompleted += new SendCompletedEventHandler(ss_SendCompleted);
                  ss.EnableSsl = true;
                  ss.Timeout = 10000;
                  ss.DeliveryMethod = SmtpDeliveryMethod.Network;
                  ss.UseDefaultCredentials = false;
                  ss.Credentials = new NetworkCredential("meuser", "mepassword");
                  string userState = "test message1";
                  ss.SendAsync(message, userState);
                  lbl3.Enabled = true;
                  lbl3.Visible = true;
                  lbl3.BackColor = Color.DarkSeaGreen;
                  lbl3.Text = "Sending email please wait";
                  SendLogFile.Enabled = false;
              }
  
              catch (Exception errors)
              {
                  Logger.Write("Error sending message :" + errors);
              }
          }
  
          private void ss_SendCompleted(object sender, AsyncCompletedEventArgs e)
          {
              timerdelay = 0;
              timer3.Start();
              String token = (string)e.UserState;
              if (e.Cancelled)
              {
                  Logger.Write("[{0}] Send canceled." + token);
                  SendLogFile.Enabled = true;
              }
              if (e.Error != null)
              {
                  lbl3.Enabled = true;
                  lbl3.Visible = true;
                  lbl3.BackColor = Color.DarkSeaGreen;
                  lbl3.Text = "There was a problem with sending the log file please try again later and check the log file for more information";
                  Logger.Write("There was a problem with sending the log file please try again later and check the log file for more information :" + e.Error.ToString());
                  SendLogFile.Enabled = true;
              }
              else
              {
                  SendLogFile.Enabled = true;
                  message.Dispose();
                  lbl3.Enabled = true;
                  lbl3.Visible = true;
                  lbl3.BackColor = Color.DarkSeaGreen;
                  lbl3.Text = "Email have been sent successfully";
                  Logger.Write("Attached log file have been emailed successfully");
                  lbl1.BringToFront();
                  lbl1.Visible = true;
                  lbl1.Text = "The log file have been sent on: " + DateTime.Now;
              }
          }
  </code></pre>
  
  <p>The idea in general is to use the email like a server to transfer a push messages like updates. So when a user is downloading my program and run if any X minutes there a new email he will see it in the program like a new update.</p>