title: C# Customising MailAddress.From field not working
body: <p>I am trying to send Emails from my custom address to users using C# and googles smtp service. My problem is that when the when the user receives the message it is displayed <code>admin@customDomain.co.uk &lt;myAddress@gmail.com&gt;</code> in the from section of the email.</p>
  
  <p>My problem is that I want the user to see <code>admin@customDomain.co.uk &lt;admin@customDomain.co.uk&gt;</code>. Is this possible using the google service? Or should I look at some other option? If so what?</p>
  
  <p>I have tried the answers on <a href="https://stackoverflow.com/questions/2737699/sending-emails-in-asp-net-with-specific-name-instead-of-sender-email">this</a> thread but non worked and I also found this <a href="https://gmail.googleblog.com/2009/07/send-mail-from-another-address-without.html" rel="nofollow noreferrer">google blog post</a> but I cant work out how it can solve my issue</p>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>    string SmtpAddress = "smtp.gmail.com";
      int MyPort = 587;
      bool enableSSL = true;
      string MyPassword = "somePassword";
      string MyUsername = "aUsername";
  
      public string EmailFrom = "admin@customDomain.co.uk";
      public string Subject = "Test Subject";
  
  public void Send(string body, BL.Customer customer)
      {
          using (MailMessage message = new MailMessage())
          {
              message.To.Add(new MailAddress(customer.EmailAddress));
              if (!String.IsNullOrEmpty(customer.SCEmailAddress))
              {
                  //message.To.Add(new MailAddress(customer.SCEmailAddress));
              }
              message.From = new MailAddress(EmailFrom, EmailFrom);
              message.Subject = Subject;
              message.Body = string.Format(body);
              message.IsBodyHtml = true;
  
              using (var smtp = new SmtpClient())
              {
                  var credential = new NetworkCredential
                  {
                      UserName = MyUsername,
                      Password = MyPassword
                  };
                  smtp.Credentials = credential;
                  smtp.Host = SmtpAddress;
                  smtp.Port = MyPort;
                  smtp.EnableSsl = enableSSL;
                  try
                  {
                      smtp.Send(message);
                  }
                  catch (SmtpException se)
                  {
                      throw se;
                  }
              }
          }
      }
  </code></pre>