I am dynamically generating a number of different types of files based upon a GridView in ASP.NET - an Excel spreadsheet and a HTML file. I am doing so using this code (this is
protected void btnSend_OnClick(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
byte[] data = new byte[1024];
MemoryStream stream = new MemoryStream(data);
Attachment attach = new Attachment(stream, "Attachment file name");
mail.Attachments.Add(attach);
new SmtpClient().Send(mail);
}