在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
public void MailSend(string[] mails) { try { MailMessage message = new MailMessage(); foreach (string mail in mails) { message.To.Add(mail);//收件人地址 } if (txtCC.Text != "") { string[] cc = txtCC.Text.Split(';'); foreach (string str in cc) { message.CC.Add(str);//抄送的地址 } } message.From = new MailAddress("[email protected]", "管理员", System.Text.Encoding.UTF8); message.Subject =txtTitle.Text.Trim(); //邮件主题 message.IsBodyHtml = true;//是否为html格式的邮件 message.Body = FreeTextBox1.Text;//邮件的内容 string smtp = "smtp.yeah.net";//因为我用的是163的邮箱,所以这里用到的是用163的 SmtpClient sc = new SmtpClient(smtp);//发送邮件用到的smtp主机(用不同的邮箱,stmp定义则不同) string email = "email";//ConfigurationManager.AppSettings["email"]; string pwd = "pwds";//ConfigurationManager.AppSettings["email_pwd"]; sc.Credentials = new System.Net.NetworkCredential(email,pwd);//邮箱账号与密码 sc.Send(message); //发送邮件 } catch (SmtpException se) { Response.Write("<script>alert('"+se.ToString()+"');</script>"); } }
|
请发表评论