title: Mask From Email Address smtp asp.net gmail
body: <p>I am using MailMessage to send email from a web application. I believe I have the correct code in to "mask" the from name in the <code>SendEmail()</code> function</p>
  
  <pre><code>public static void SendEmail(string toAddress, string ccAddress, string bccAddress, string subject, string body, MemoryStream attachment, string attachmentName, bool isHtml, string fromAlias = "info@cipollainsurance.com")
      {
          using (MailMessage message = new MailMessage())
          {
              AlternateView htmlView = AlternateView.CreateAlternateViewFromString(AddHeaderAndFooter(subject, body).ToString(), new System.Net.Mime.ContentType("text/html"));
  
              var resources = LoadResources();
  
              foreach (LinkedResource resource in resources)
              {
                  htmlView.LinkedResources.Add(resource);
              }
  
              message.AlternateViews.Add(htmlView);
  
              if (!string.IsNullOrEmpty(toAddress))
              {
                  var addresses = toAddress.Split(',', ';');
  
                  foreach (string address in addresses)
                  {
                      message.To.Add(address);
                  }
              }
  
              if (!string.IsNullOrEmpty(ccAddress))
              {
                  var ccAddresses = ccAddress.Split(',', ';');
  
                  foreach (string cc in ccAddresses)
                  {
                      message.CC.Add(cc);
                  }
              }
  
              if (!string.IsNullOrEmpty(bccAddress))
              {
                  var bccAddresses = bccAddress.Split(',', ';');
  
                  foreach (string bcc in bccAddresses)
                  {
                      message.Bcc.Add(bcc);
                  }
              }
  
              if (!string.IsNullOrWhiteSpace(fromAlias))
              {
                  message.Sender = new MailAddress("info@cipollainsurance.com", fromAlias, System.Text.Encoding.ASCII);
              }
              message.Body = body;
              message.BodyEncoding = System.Text.Encoding.UTF8;
              message.Subject = subject;
              message.SubjectEncoding = System.Text.Encoding.UTF8;
              message.IsBodyHtml = isHtml;
              message.From = new MailAddress("info@cipollainsurance.com", "Cipolla Insurance");
  
              if (attachment != null)
              {
                  message.Attachments.Add(new Attachment(attachment, attachmentName));
              }
  
              SmtpClient client = new SmtpClient();
              client.Send(message);
          }
      }
  </code></pre>
  
  <p>However the from email address still says <code>email</code> and <code>email@webedgemedia.com</code> which is what is specified in <code>web.config</code>.</p>
  
  <pre><code>&lt;smtp from="info@cipollainsurance.com" deliveryMethod="Network"&gt;
      &lt;network host="smtp.gmail.com" enableSsl="true" port="587" password="myPassword" userName="email@webedgemedia.com" /&gt;
  &lt;/smtp&gt;
  </code></pre>
  
  <p>Can someone identify what I'm missing to send the email out as info@cipollainsurance.com?</p>