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);
}
}
展开
 我来答
帐号已注销
2010-05-10
知道答主
回答量:27
采纳率:0%
帮助的人:15万
展开全部
这个是我写的,你可以看一下,用的是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;
}
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式