title: Change display name of sender in mail when sender mail is coming from web config in C#
body: <p>Below is my code for sending mail...</p>
  
  <pre><code> public void SendBy(string to, string subject, string body)
  {
      MailMessage nM = new System.Net.Mail.MailMessage();
  
      nM.To.Add("abc@compulynx.org");
      nM.Subject = subject;
      nM.Attachments.Add(new Attachment(oStream, Fname));
      nM.Body = body;
      System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
      System.Net.Configuration.MailSettingsSectionGroup settings = (System.Net.Configuration.MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");
  
      SmtpClient client = new SmtpClient(settings.Smtp.Network.Host);
      client.Credentials = new NetworkCredential(settings.Smtp.Network.UserName, settings.Smtp.Network.Password);
  
      client.EnableSsl = true;
      client.Send(nM);
  }
  </code></pre>
  
  <p>and this is my web config code...</p>
  
  <pre><code>&lt;system.net&gt;
       &lt;mailSettings&gt;
          &lt;smtp deliveryMethod="Network" from="xyz@gmail.com" &gt;
              &lt;network host="smtp.gmail.com" 
                      defaultCredentials="false" userName="xyz@gmail.com" password="xyz"
                      port="587"/&gt;
          &lt;/smtp&gt;
      &lt;/mailSettings&gt;
  &lt;/system.net&gt;
  </code></pre>
  
  <p>this code is working fine but how i will change the sender display name,normally we use like this</p>
  
  <pre><code> mM.From = new MailAddress("xyz@gmail.com","xyz");
  </code></pre>
  
  <p>but in my case I am not writing sender mail address any where , I am just getting from web config,then how I will change that name..i have current login user in my session,I want to display that name as a sender...</p>