如何在c#Winform中将Datagridview作为电子邮件发送? [英] How to Sending Datagridview as email message in c# Winform?

查看:118
本文介绍了如何在c#Winform中将Datagridview作为电子邮件发送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从sql server检索数据并将其存储在datagridview中。在此之后,我需要向我的客户发送邮件。无论datagridview中有什么数据,我都需要将datagridview数据作为消息发送给客户端。我尽我所能,但我无法在消息中添加datagridview数据。下面是我的代码请帮我...





从sql server加载datagridview





I''m retrieve the data from sql server and store it in datagridview . After this I need to send mail to my client . whatever data is in datagridview , I need to sent the datagridview data''s to client as message . I tried my best but i cant add datagridview data in message. below is my code pls help me...


loading datagridview from sql server


DataTable datatable = new DataTable();
     Connection();
     datatable.Load(new SqlCommand("select * from StudentMarksHistory", cs).ExecuteReader());
     dataGridView1.DataSource = datatable.DefaultView;
     cs.Close();







向客户发送邮件






sending mail to client

foreach (DataGridViewRow row in dataGridView1.Rows)
          {
                mailBody +="<tr>";
                foreach (DataGridViewCell cell in row.Cells)
                {
                   mailBody +="<td stlye='color:blue;'>" +cell.Value + "</td>";
                }
                mailBody +="</tr>";
          }
          mailBody +="</table>";

          //your rest of the original code
          mail.Body = mailBody;
string mailBody = "<table width='100%' style='border:Solid 1px Black;'>";

推荐答案

亲爱的朋友,



大约55,000,000个结果将网格数据发送到电子邮件?



请不要忘记将此标记为您的答案,如果它可以帮助您。



问候



Varun Sareen
Dear Friend,

About 55,000,000 results sending grid data to email?

Please don''t forget to mark this as your answer if it helps you out.

Regards

Varun Sareen


这篇关于如何在c#Winform中将Datagridview作为电子邮件发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆