title: Tracking whether sent mail is read or not
body: <p>I have searched many articles and have found some code, but it's not working for me.</p>
  
  <p>My index.aspx.cs page code is: </p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
   {
      if (checkIfRequested(this.Context.Request))
      {           
          //receiver had already requested the image, hence send back a not modified result
          Response.StatusCode = 304;
          Response.SuppressContent = true;
      }
      else
      {
          int emailId = 0;
          if (!string.IsNullOrEmpty(Request.QueryString["emailId"]) &amp;&amp; int.TryParse(Request.QueryString["emailId"], out emailId))
          {
              Session["image"] = Request.QueryString["emailId"];
              lblid.Text = Convert.ToString(Session["image"]);
  
  
              //The email with emailId has been opened, so log that in database
          }
          else
          {
              if (Request.QueryString["emailId"] != null)
              {
                  lblid.Text = Convert.ToString(Request.QueryString["emailId"]);
              }
              string str = "&lt;script&gt;alert('empty')&lt;/script&gt;";
              Page.RegisterStartupScript("popup", str);
          }
  
          //Send the single pixel gif image as response
          byte[] imgbytes = Convert.FromBase64String("R0lGODlhAQABAIAAANvf7wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
          Response.ContentType = "image/gif";
          Response.AppendHeader("Content-Length", imgbytes.Length.ToString());
          Response.Cache.SetLastModified(DateTime.Now);
          Response.Cache.SetCacheability(HttpCacheability.Public);
          Response.BinaryWrite(imgbytes);
      }
  }
  
  private bool checkIfRequested(HttpRequest req)
  {
      // check if-modified-since header to check if receiver has already requested the image in last 24 hours
      return req.Headers["If-Modified-Since"] == null ? false : DateTime.Parse(req.Headers["If-Modified-Since"]).AddHours(24) &gt;= DateTime.Now;
  }
  </code></pre>
  
  <p>My index.aspx page seems as: </p>
  
  <pre><code>&lt;body&gt;
  &lt;form id="form1" runat="server"&gt;
  &lt;asp:Label ID="lblid" runat="server" Text=""&gt;&lt;/asp:Label&gt;   
  &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I used to send email to my own Gmail id from my aspx page like:</p>
  
  <pre><code>String MailContent = "";
  MailContent += "&lt;img src='http://WWW.mywebsitename.com/index.aspx?emailId=1' width='1' height='1' /&gt;
  client = new SmtpClient();
  client.UseDefaultCredentials = false;
  client.Credentials = new System.Net.NetworkCredential("Myemailidofhmail", "mypassword");
  client.Port = 25;
  client.Host = "smtp.gmail.com";
  client.EnableSsl = true; 
  mailto = "mitesh@gmail.com";
  message = MailContent.ToString();
  msg = new System.Net.Mail.MailMessage();
  msg.To.Add(mailto);
  </code></pre>
  
  <p>Here the mail is coming successfully to my Gmail account on <code>mitesh@gmail.com</code> id, but when I open that email from my account I am not getting <code>Request.QueryString["emailId"]</code> value as 1 to my <code>index.aspx</code></p>