コードは以下のとおりです。メールにグリッドを追加するにはどうすればよいですか。
private void button1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @"Data Source=10.1.1.1;Initial Catalog=xxx;Integrated Security=True";
SqlCommand command = new SqlCommand();
command.Connection= conn;
command.CommandText ="Select top 10 * from tablea";
DataTable data = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = command;
adapter.Fill(data);
gvSendEmail.DataSource = data;
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("10.1.1.11");
mail.From = new MailAddress("xxxx@xxxxx", "xxxx");
mail.To.Add("xxxxx@xxxxx.xxx");
mail.Subject = "Test Mail";
mail.Body = "This is test email";
mail.Body += "Please check below data ";
SmtpServer.Port = 25;
SmtpServer.Credentials = new System.Net.NetworkCredential("xxxx", "xxxx");
SmtpServer.EnableSsl = false;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}