首页 新闻 赞助 找找看

asp.net mvc 群发邮件

0
悬赏园豆:20 [已关闭问题] 关闭于 2013-07-30 14:05

asp.net mvc 群发邮件 每个人发送的内容不一样 有这样的群发吗?各位大牛们该怎么写?

cnns的主页 cnns | 初学一级 | 园豆:1
提问于:2013-07-29 15:27
< >
分享
所有回答(4)
0

这东西,不关MVC的事。

dotnetgeek | 园豆:482 (菜鸟二级) | 2013-07-29 15:56
0

发送邮件,有个是内容的参数,每次讲这个参数设置为动态的就行了,其他的都一样

jojo219 | 园豆:202 (菜鸟二级) | 2013-07-29 15:58
0

群发,就是把接收地址列表遍历一下,把每一个都发一下,就变成了群发.

        /// <summary>
        /// 发送邮件,附加附件
        /// </summary>
        /// <param name="excelPath">附件地址</param>
        /// <returns></returns>
        public static bool SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody)
        {
            try
            {
                System.Net.Mail.SmtpClient client = new SmtpClient(strSmtpServer);
                client.Timeout = 9999999;
                client.UseDefaultCredentials = false;
                client.Credentials = new System.Net.NetworkCredential(strFrom, strFromPass);
                client.DeliveryMethod = SmtpDeliveryMethod.Network;

                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(strFrom, strto, strSubject, strBody);
                //System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(excelPath);
                
                //message.Attachments.Add(attachment);
                message.BodyEncoding = System.Text.Encoding.UTF8;
                message.IsBodyHtml = true;
                client.Send(message);
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
只会造轮子 | 园豆:2274 (老鸟四级) | 2013-07-29 16:26
0

这和MVC关系不大,定义一个消息类(发送人,收件人,内容,附件等),遍历这样的一个数组或者List,每次发送一封邮件,就是群发了。

发的数量多了就是群发了·

幻天芒 | 园豆:37175 (高人七级) | 2013-07-29 20:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册