我的C# 程序需要一个群发邮件的功能,请问有第三方插件吗

解决方案 »

  1.   

    源码:
    http://download.csdn.net/source/3334178http://download.csdn.net/source/2993169
    http://download.csdn.net/source/3131432
      

  2.   


    using System.Net.Mail;
    using System.Net;
            /// <summary>
            /// 发送电子邮件
             /// </summary>
            /// <param name="to"></param>
            /// <param name="from"></param>
            /// <param name="subject">主题</param>
            /// <param name="body">正文</param>
            /// <param name="userName">发件用户名</param>
            /// <param name="password">发件密码</param>
            /// <param name="smtpHost"></param>
            public static bool  Send(string to, string from, string subject, string body, string userName, string password, string smtpHost, string CC)
            {
                try
                {
                    MailAddress From = new MailAddress(from);
                    MailAddress To = new MailAddress(to);
                    MailMessage message = new MailMessage(From, To);
                    message.Subject = subject;//设置邮件主题 
                    message.IsBodyHtml = true;//设置邮件正文为html格式 
                    message.Body = body;//设置邮件内容 
                    if (CC != null && CC != "")
                        message.CC.Add(CC);//抄送
                    message.Priority = MailPriority.High;//优先级
                    // message.Attachments.Add(new Attachment ( @"/new1/photo/small/103427.jpg"));//附件
                    SmtpClient client = new SmtpClient(smtpHost);
                    //设置发送邮件身份验证方式 
                    //注意如果发件人地址是[email protected],则用户名是abc而不是[email protected] 
                    client.Credentials = new System.Net.NetworkCredential(userName, password);
                    client.Send(message);
                    message.Dispose();
                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }
            }