title: Send DataSet data email via attachment Excel File xls ( Not Creating Excel File ) C#
body: <p>I want to send DataSet data with email excel file attachment in C# but I don't want to create Excel file physically. It can be do with MemoryStream but I couldn't.</p>
  
  <p>Another problem I want to set Excel file's encoding type because data may be Russian or Turkish special character.</p>
  
  <p>Please help me...</p>
  
  <p>Here is my sample code...</p>
  
  <pre><code>&lt;!-- language: c# --&gt;
  var response = HttpContext.Response;
  
  response.Clear();
  response.Charset = "utf-8";
  response.ContentEncoding = System.Text.Encoding.Default;
  
  GridView excelGridView = new GridView();
  excelGridView.DataSource = InfoDataSet;
  excelGridView.DataBind();
  
  excelStringWriter = new StringWriter();
  HtmlTextWriter htw = new HtmlTextWriter(excelStringWriter);
  excelGridView.RenderControl(htw);
  
  byte[] ExcelData = emailEncoding.GetBytes(excelStringWriter.ToString());
  MemoryStream ms = new MemoryStream(ExcelData);
  
  mailMessage.Attachments.Add(new Attachment(ms, excelFileName, "application/ms-excel"));
  &lt;!-- language: c# --&gt;
  </code></pre>