这个asp.net实现发邮件功能,但是我这个不能发送邮件,,大神些,帮我看看
System.Net.Mail.SmtpClientclient=newSystem.Net.Mail.SmtpClient();//这里使用QQ的邮箱来发送测试,如果是...
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
//这里使用QQ的邮箱来发送测试,如果是其它邮箱,请根据其它邮箱POP3/IMAP/SMTP服务来设置
client.Host = "smtp.qq.com";
// client.Host = "smtp.163.com";
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential("1406039700@qq.com", "324175lhl");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("1406039700@qq.com", ds.Tables[0].Rows[j]["menber_email"].ToString());
message.Subject = "PICC人保财险";
message.Body = "你好,你的保险已到期!";
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
//添加附件
// Attachment data = new Attachment(@"附件路径", System.Net.Mime.MediaTypeNames.Application.Octet);
// message.Attachments.Add(data);
try
{
client.Send(message);
Response.Write("<script>alert('邮件发送成功!');</script>");
}
catch
{
Response.Write("<script>alert('邮件发送失败!');</script>");
// throw;
} 展开
//这里使用QQ的邮箱来发送测试,如果是其它邮箱,请根据其它邮箱POP3/IMAP/SMTP服务来设置
client.Host = "smtp.qq.com";
// client.Host = "smtp.163.com";
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential("1406039700@qq.com", "324175lhl");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("1406039700@qq.com", ds.Tables[0].Rows[j]["menber_email"].ToString());
message.Subject = "PICC人保财险";
message.Body = "你好,你的保险已到期!";
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
//添加附件
// Attachment data = new Attachment(@"附件路径", System.Net.Mime.MediaTypeNames.Application.Octet);
// message.Attachments.Add(data);
try
{
client.Send(message);
Response.Write("<script>alert('邮件发送成功!');</script>");
}
catch
{
Response.Write("<script>alert('邮件发送失败!');</script>");
// throw;
} 展开
1个回答
焱人科技
2024-10-30 广告
2024-10-30 广告
企业邮箱注册咨询热线:13350877465袁经理企业邮箱拥有自研飞天安全攻防体系,实现企业邮件安全畅邮,存储不限容量,同时支持企业多终端登录、钉+邮绑定、多域名管理、个性化定制企业形象等众多功能,为企业提供7*24小时VIP技术服务支持,...
点击进入详情页
本回答由焱人科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询