如何将一个邮件发送到多个mailid mailid列表在数据库中维护 [英] how to send one mail to multiple mailid the mailid list is maintained in database

查看:270
本文介绍了如何将一个邮件发送到多个mailid mailid列表在数据库中维护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我必须发送一封邮件到多个mailid'si数据库中有mailid的列表.我该如何发送.(例如:订阅您可以在某些网站中找到)任何一个plz都可以帮助我.


i have to send one mail to multiple mailid''s i have the list of mailid''s in my database.how can i send like that.(ex:subscribing u can find in some websites) any one plz help me.

推荐答案

try
            {
                SmtpClient client = new SmtpClient();
                client.Host = "smtp.gmail.com";
                client.Port = 587;
                client.Credentials = new NetworkCredential("gmail ID","password");

                client.EnableSsl = true;
                MailAddress from = new MailAddress("Gmail ID");
                MailMessage msg = new MailMessage();
                msg.From = from;

                string s11 = "select Email ID from Table";
                SqlDataAdapter add = new SqlDataAdapter(s11, c.getcon());
                DataSet ds2 = new DataSet();
                add.Fill(ds2);

                if (ds2.Tables[0].Rows.Count != 0)
                {
                    arra = new string[ds2.Tables[0].Rows.Count];
                    for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
                    {
                        arra[i] = System.Convert.ToString(ds2.Tables[0].Rows[i][0].ToString());
                    }
                    for (int i1 = 0; i1 < arra.Length; i1++)
                    {
                        msg.To.Add(arra[i1]);
                        msg.Subject = subject name;
                        msg.Body = body;
                        client.Send(msg);
                        Label3.Text = "Message Send Successfully";
                    }
                }
}
catch(Exception e1)
{
}



享受吧...



Enjoy it...


步骤:
1.从数据库获取邮件ID列表.
2.在for循环中输入邮件ID的数量
3.将电子邮件一一发送到邮件ID's

以下发送电子邮件的提示:在C#中使用以下方式发送电子邮件或没有附件:通用例程. [ ^ ]

试试!
Steps:
1. Get the mail id list from database.
2. Go in a for loop with the number of mail id''s
3. send email one by one to the mail-id''s

Following tip for sending email: Sending an Email in C# with or without attachments: generic routine.[^]

Try!


只需将所有用分号作为分隔符的邮件ID绑定到字符串中,然后在收件人"列表中分配它,即可立即将邮件发送给所有收件人.无需为每个邮件发送相同的邮件.
Just bind all mail Ids with a semicolon as a separator in a string and assign it in To list, that sends the mail to all the recipients at once. No need of sending the same mail for each one of them.


这篇关于如何将一个邮件发送到多个mailid mailid列表在数据库中维护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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