title: How can I send an email via C# and get the email address of the sender without letting him send the message from his account
body: <p>I have a website where the user must send certain info about his car and these information contain also his email address so that I can reply and send him a message.</p>
  
  <p>the messages in this website are being sent and my code is:</p>
  
  <pre><code> protected void Button1_Click(object sender, EventArgs e)
      {   
  
          try
          {
              MailMessage mail = new MailMessage();
              SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
  
  
              mail.To.Add("myemailaddress");
  
  
              SmtpServer.Port = 587;
              SmtpServer.UseDefaultCredentials = false;
             SmtpServer.Credentials = new System.Net.NetworkCredential("myemailaddress, "mypassword");
  
              mail.From = new MailAddress(TextBox3.Text);//gets the email address of the sender
              SmtpServer.EnableSsl = true;
  
  
  
              mail.Subject = "subject";
              mail.Body = "body";
  
              SmtpServer.Send(mail);
  
  
  
              string script = "alert(\"Email was sent!\");";
              ScriptManager.RegisterStartupScript(this, GetType(),
                                    "ServerControlScript", script, true);
  
          }
  
          catch (Exception ex)
          {
              // Response.Write(ex.ToString());
              string script = "alert(\"Email was not sent!\");";
              ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);
  
  
          }
  </code></pre>
  
  <p>That's working perfectly but as you can see the message is being sent from my email address and to my email address not from the sender's account.</p>
  
  <p>So I can't reply unless I get the email address sent by the sender which is contained in textbox3.</p>
  
  <p>The problem is that the sender can write his email incorrectly that way I won't be able to reply to his messages. I thought I can let him retype his email address in a second textbox and I would check if both textboxes contain same email address the message will be sent otherwise it won't get sent. but that is not really a good idea; what can I do to get the correct email address of the sender?</p>
  
  <p>I am doing that because as you know Gmail needs authentication and I don't want to ask the sender to put his password.</p>