通过 vb.net Web 应用程序发送电子邮件
我正在尝试通过我的 VB.net Web 应用程序发送一封简单的纯文本电子邮件。
我已按照此处的说明进行操作: http://www.systemnetmail.com/faq/3.1.1.aspx
但是,无论我使用什么电子邮件地址,我都会不断收到“无法连接到远程服务器”的消息。
这是我的代码
'Create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("<email1>")
mail.To.Add("<email2>")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is a sample body"
'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)
为什么这不起作用?
I'm trying to send a simple plain-text email through my VB.net web application.
I've followed the instructions here:
http://www.systemnetmail.com/faq/3.1.1.aspx
But, regardless of what email addresses I use, I keep getting the message "unable to connect to the remote server".
Here is my code
'Create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("<email1>")
mail.To.Add("<email2>")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is a sample body"
'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)
Why is this not working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确定您的电脑(127.0.0.1,环回IP)是SMTP服务器吗?
Dim smtp As New SmtpClient(host)
表示您的电脑尝试连接到 smtp 服务器主机并使用它发送电子邮件。检查一下,你就会解决你的问题...
只是尝试一下:将 127.0.0.1 更改为您在电子邮件软件中使用的默认 SMTP 服务器,看看会发生什么...
更多:捕获异常(如果引发)并记下消息...
Are you sure that your pc (127.0.0.1, loopback ip) is a SMTP server?
Dim smtp As New SmtpClient(host)
means that your pc tries to connect to smtp server host and use it to send an email.Check that and you gonna solve your problem...
Just to try: change 127.0.0.1 with the default SMTP server you use in your email software and see what happens...
More: catch the exception (if one is raised) and take note of the message...
尝试添加此
并检查您的防火墙设置,也许该端口已关闭。
Try to add this
and review your firewall settings, maybe the port is closed.