Sending Datagridview to email

后端 未结 3 590
无人及你
无人及你 2021-01-07 03:23

i made a code that i can send an email to gmail.com with c# and it is working very well. Now i want to put my datagridview1 in the email body and send it. Somone can show me

3条回答
  •  一生所求
    2021-01-07 04:30

    You need to iterate over the Rows collection of your datagridview, extract the values and assign to your mail.Body. A crude example: -

    StringBuilder sb = new StringBuilder();
    foreach (DataRow row in datagridview1.Rows)
    {
          sb.AppendLine(row["ROW NAME"].ToString());
    }
    
    mail.Body = sb.ToString();
    

提交回复
热议问题