通过vb.net Web应用程序发送电子邮件 [英] Send email via vb.net web application

查看:181
本文介绍了通过vb.net Web应用程序发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我按照这里的说明:
http://www.systemnetmail.com/faq/3.1.1.aspx



但是,无论使用什么电子邮件地址,我都会收到无法连接到远程服务器的消息。



这是我的代码

 '创建邮件
作为新的MailMessage()

'设置地址
mail.From =新的MailAddress(< email1>)
mail.To.Add(< email2>)

'设置内容
mail.Subject =这是一封电子邮件
mail.Body =这是一个示例体

'发送消息
Dim smtp As New SmtpClient(127.0.0.1)
smtp.Send(mail)

为什么这不起作用?

解决方案

你确定你的电脑(127.0.0.1, ack ip)是SMTP服务器?

Dim smtp As New SmtpClient(host)意味着您的电脑尝试连接到smtp服务器主机并使用它发送电子邮件。

检查并解决您的问题...

只是尝试:更改 127.0.0.1 使用您在电子邮件软件中使用的默认SMTP服务器,看看会发生什么...

更多:捕获异常(如果有人提出)并记下消息...


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?

解决方案

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...

这篇关于通过vb.net Web应用程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆