asp.net简单邮件发送,请帮我看哈问题
publicvoidSendMailUseGmail(){System.Net.Mail.MailMessagemsg=newSystem.Net.Mail.MailMe...
public void SendMailUseGmail()
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add("1129037902@qq.com");
msg.From = new MailAddress("771482456@qq.com", "ssfsdfsdfds", System.Text.Encoding.UTF8);
msg.Subject = "这是测试邮件";
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = "邮件内容";
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = false;
msg.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("771482456@qq.com", "xiangyu1990");
client.Port = 2239;
client.Host = "192.168.1.102";--这点该怎么写呀
client.EnableSsl = true;
try
{
client.Send(msg);
Response.Write("发送成功");
}
catch (System.Net.Mail.SmtpException ex)
{
Response.Write(ex.Message);
}
} 展开
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add("1129037902@qq.com");
msg.From = new MailAddress("771482456@qq.com", "ssfsdfsdfds", System.Text.Encoding.UTF8);
msg.Subject = "这是测试邮件";
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = "邮件内容";
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = false;
msg.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("771482456@qq.com", "xiangyu1990");
client.Port = 2239;
client.Host = "192.168.1.102";--这点该怎么写呀
client.EnableSsl = true;
try
{
client.Send(msg);
Response.Write("发送成功");
}
catch (System.Net.Mail.SmtpException ex)
{
Response.Write(ex.Message);
}
} 展开
展开全部
这个是我写的,你可以看一下,用的是163的服务。
public void GetSend(string MessageFrom, string MessageTo, string MessageSubject, string MessageBody)
{
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress(MessageFrom);
message.To.Add(new MailAddress(MessageTo));
message.Subject = MessageSubject;
message.SubjectEncoding = Encoding.UTF8;
message.Body = MessageBody;
SmtpClient client = new SmtpClient("smtp.163.com");
client.Credentials = new NetworkCredential("milanihk", "83882171");
client.Send(message);
Page.RegisterClientScriptBlock("js", "<script>alert('Thank you,Submit Message Successful!');location.href='Massage.aspx?MenuID=020502';</script>");
}
catch (Exception ex)
{
throw ex;
}
}
public void GetSend(string MessageFrom, string MessageTo, string MessageSubject, string MessageBody)
{
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress(MessageFrom);
message.To.Add(new MailAddress(MessageTo));
message.Subject = MessageSubject;
message.SubjectEncoding = Encoding.UTF8;
message.Body = MessageBody;
SmtpClient client = new SmtpClient("smtp.163.com");
client.Credentials = new NetworkCredential("milanihk", "83882171");
client.Send(message);
Page.RegisterClientScriptBlock("js", "<script>alert('Thank you,Submit Message Successful!');location.href='Massage.aspx?MenuID=020502';</script>");
}
catch (Exception ex)
{
throw ex;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询