用户订购时如何向管理员发送电子邮件? [英] How do I send email to admin when user order?

查看:140
本文介绍了用户订购时如何向管理员发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我需要将数据库ordre_linie中的信息发送到我的电子邮箱吗?



Hi
I need to send the information from my database ordre_linie to my email?

private void sendEmail()
     {
         SqlConnection conn = new SqlConnection();
         conn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

         SqlCommand cmd = new SqlCommand();
         cmd.Connection = conn;
         cmd.CommandText = "SELECT ordre_linie_id FROM ordre_linie";


         //Create instance of MailMessage Class
         MailMessage msg = new MailMessage();
         //Assign From mail address
         msg.From = new MailAddress(TextBox_mail.Text);
         msg.To.Add(new MailAddress("my email"));
         msg.Subject = "Ordre fra bruger";

         msg.Body = "Ordre indeholder";

         msg.Body += ordre_linie_id ;

         msg.IsBodyHtml = true;

         SmtpClient SmtpServer = new SmtpClient();

         SmtpServer.Host = "smtp.gmail.com";

         SmtpServer.Port = 587;

         SmtpServer.Credentials = new System.Net.NetworkCredential("my email", "xxxxx");

         SmtpServer.EnableSsl = true;

         SmtpServer.Send(msg);

     }





/ Tina



/Tina

推荐答案

你的查询将返回N个记录,所以这里是我要添加的解决方案



你必须执行你的查询并在datareader中捕获结果< br $>


your Query will return N number of records so here is a solution i am adding

you have to execute your query and capture the result in datareader

SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
ordre_linie_id= Convert.ToInt64(reader["ordre_linie_id"]);
}
reader.Close();





那么你必须实现for循环.... 。???



如果你想实现单个记录,那么请在你的查询中指定条件。



then you will have to implement for loop .....???

if you want to implement for single record then please specify where condition in your Query.


你有没有注意到,你永远不会执行你的查询?
Have you noticed, that you never execute your query?


这篇关于用户订购时如何向管理员发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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