C# 怎样读取用户信息 一键发送邮件
展开全部
给你个例子:
private void SendMail()
{
MailAddress from = new MailAddress("2695707923@qq.com");
MailAddress to = new MailAddress("hpr2013@126.com");
MailMessage objMessage = new MailMessage(from, to);
objMessage.Subject = "有人在网站上留言了";
StringBuilder MailContent = new StringBuilder();
MailContent.Append("<div style='font-size:13px; line-height:25px;'><b>所选服务:<则闹散/b>");
MailContent.Append(this.serv);
MailContent.Append("<br /><b>孙氏留言内容:</b>");
MailContent.Append(this.want);
MailContent.Append("<br /><b>发件人:</b>");
MailContent.Append(this.userName);
MailContent.Append("<br /><b>电话:弯竖</b>");
MailContent.Append(this.userPhone);
MailContent.Append("<br /><b>发送时间:</b>");
MailContent.Append(DateTime.Now.ToString());
MailContent.Append("<br /></div>");
AlternateView htmlBody = AlternateView.CreateAlternateViewFromString(MailContent.ToString(), null, "text/html");
objMessage.AlternateViews.Add(htmlBody);
SmtpClient client = new SmtpClient("smtp.qq.com", 25);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = new System.Net.NetworkCredential("2695707923", "haipurun2013");
try
{
client.Send(objMessage);
}
catch
{
}
}
private void SendMail()
{
MailAddress from = new MailAddress("2695707923@qq.com");
MailAddress to = new MailAddress("hpr2013@126.com");
MailMessage objMessage = new MailMessage(from, to);
objMessage.Subject = "有人在网站上留言了";
StringBuilder MailContent = new StringBuilder();
MailContent.Append("<div style='font-size:13px; line-height:25px;'><b>所选服务:<则闹散/b>");
MailContent.Append(this.serv);
MailContent.Append("<br /><b>孙氏留言内容:</b>");
MailContent.Append(this.want);
MailContent.Append("<br /><b>发件人:</b>");
MailContent.Append(this.userName);
MailContent.Append("<br /><b>电话:弯竖</b>");
MailContent.Append(this.userPhone);
MailContent.Append("<br /><b>发送时间:</b>");
MailContent.Append(DateTime.Now.ToString());
MailContent.Append("<br /></div>");
AlternateView htmlBody = AlternateView.CreateAlternateViewFromString(MailContent.ToString(), null, "text/html");
objMessage.AlternateViews.Add(htmlBody);
SmtpClient client = new SmtpClient("smtp.qq.com", 25);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = new System.Net.NetworkCredential("2695707923", "haipurun2013");
try
{
client.Send(objMessage);
}
catch
{
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
Zoho Mail
2024-11-18 广告
2024-11-18 广告
作为卓迈(北京)技术有限公司的工作人员,我们推荐使用Gmail、Outlook等国际知名的电子邮箱服务来在国外收发邮件。这些邮箱服务拥有广泛的国际覆盖和稳定的性能,能确保您与全球各地的合作伙伴和客户保持顺畅的沟通。同时,它们也具备强大的垃圾...
点击进入详情页
本回答由Zoho Mail提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询