asp.net 发送电子邮件问题

无锡阔微信息科技 2009-07-10 03:12:07


System.Net.Mail.SmtpException: 发送邮件失败。 ---> System.Net.WebException: 无法解析此远程名称: 'smtp.kipor.com'
在 System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
在 System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
在 System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
在 System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
在 System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
在 System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
在 System.Net.Mail.SmtpClient.GetConnection()
在 System.Net.Mail.SmtpClient.Send(MailMessage message)
--- 内部异常堆栈跟踪的结尾 ---
在 System.Net.Mail.SmtpClient.Send(MailMessage message)
在 Admin_AgentManage_AgentSendEmail.LinkButton1_Click(Object sender, EventArgs e) 位置 c:\Inetpub\wwwroot\kipor1\Admin\AgentManage\AgentSendEmail.aspx.cs:行号 98
...全文
155 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chokobo 2009-07-10
  • 打赏
  • 举报
回复
这个smtp名字对吗?直接换smtp的ip地址试试呢
  • 打赏
  • 举报
回复
怎么到我机器上就不行啊
er824088er 2009-07-10
  • 打赏
  • 举报
回复
小弟这两天也刚刚研究了一下asp.net发送邮件的问题,例子贴出来你看看,可以发送成功的!!
加分啊!!!!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MailAddress MessageFrom = new MailAddress("itcaimeng@gmail.com"); //发件人邮箱地址
string MessageTo = "design@zxxk.com"; //收件人邮箱地址
string MessageSubject = "测试例子"; //邮件主题
string MessageBody = "测试的例子终于成功了,很开心啊!"; //邮件内容
if (Send(MessageFrom, MessageTo, MessageSubject, MessageBody))
{
Response.Write("发送邮件成功");
}
else
{
Response.Write("发送邮件失败");
}
}
/// <summary>
/// 发送电子邮件
/// </summary>
/// <param name="MessageFrom">发件人邮箱地址</param>
/// <param name="MessageTo">收件人邮箱地址</param>
/// <param name="MessageSubject">邮件主题</param>
/// <param name="MessageBody">邮件内容</param>
/// <returns></returns>
public bool Send(MailAddress MessageFrom, string MessageTo, string MessageSubject, string MessageBody)
{
MailMessage message = new MailMessage();
message.From = MessageFrom;
message.To.Add(MessageTo); //收件人邮箱地址可以是多个以实现群发
message.Subject = MessageSubject;
message.Body = MessageBody;
message.IsBodyHtml = true; //是否为html格式
message.Priority = MailPriority.High; //发送邮件的优先等级

SmtpClient sc = new SmtpClient();
sc.Host = "smtp.gmail.com"; //指定发送邮件的服务器地址或IP
//sc.Port = 587; //指定发送邮件端口
sc.UseDefaultCredentials = true;
sc.EnableSsl = true;
sc.Credentials = new System.Net.NetworkCredential("itcaimeng", "19881028"); //指定登录服务器的用户名和密码
try
{
sc.Send(message); //发送邮件
}
catch(Exception e)
{
Response.Write(e.Message);
return false;
}
return true;
}
}
wenkekenihao 2009-07-10
  • 打赏
  • 举报
回复
smtp地址不对,企业邮箱一般是mail.
应该是mail.kipor.com
hecong875 2009-07-10
  • 打赏
  • 举报
回复

'smtp.kipor.com'
这个地址对吗? 你换个别的试试

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧