发送用VB code电子邮件 [英] Sending emails using VB code

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

问题描述

不知道这个问题已经被问其他地方...

Not sure if this question has been asked elsewhere...

对于我工作的一个网站项目,我创建了一个ASPX网页形式,将发送一个包含按钮点击表格的内容的电子邮件。我尝试过了,它,当我使用雅虎的SMTP服务器和测试用我个人的雅虎电子邮件地址(+指定的用户名和密码)工作。

For a website project that I'm working on, I created an ASPX web form that will send an email containing the contents of the form on button click. I tried it and it worked when I'm using the Yahoo SMTP server and testing using my personal Yahoo email address (+ specifying the username and password).

然而,当我使用SMTP服务器进行邮件的网站(我创建了一个网站一个新的管理员的电子邮件帐户后),这是行不通的。

However, it wouldn't work when I'm using the SMTP server for mail messages for the website (after I've created a new admin email account in the website).

该网站建立和运行,我能够(通过雅虎)发送电子邮件到网站的管理员的电子邮件帐户,但只是无法通过ASPX Web表单发送时。

The website is up and running and I'm able to send an email to the website's admin email account (through Yahoo) but just not when sending through the ASPX web form.

下面是code使用雅虎的SMTP服务器,它工作正常:

Here is the code for using the Yahoo SMTP server and it works fine:

    SmtpServer.Credentials = New Net.NetworkCredential("username@yahoo.com", "password")
    SmtpServer.Port = "25"
    SmtpServer.Host = "smtp.mail.yahoo.com"
    mail.From = New MailAddress("username@yahoo.com")
    mail.To.Add("username@yahoo.com")
    mail.Subject = "RE: Message Subject"
    mail.Body = "Message goes here."
    SmtpServer.Send(mail)

现在,这里是code使用我的网站的SMTP服务器不工作:

Now, here is the code for using my website's SMTP server which doesn't work:

    SmtpServer.Port = "25"
    SmtpServer.Host = "127.0.0.1"
    mail.From = New MailAddress("admin@awesomewebsite.org.au")
    mail.To.Add("admin@awesomewebsite.org.au")
    mail.Subject = "RE: Message Subject"
    mail.Body = "Message goes here."
    SmtpServer.Send(mail)

这是由承载网站的Web托管公司给出正确的端口和主机号。他们还表示,不需要用户名和密码。我也试过这个追加到code的开端,但它仍然是行不通的:

These are the correct port and host numbers given by the web hosting company that hosts the website. They also said that username and password are not needed. I also tried appending this to the beginning of the code but it still wouldn't work:

    SmtpServer.Credentials = New Net.NetworkCredential()

甚至

    SmtpServer.Credentials = New Net.NetworkCredential("", "")

我真的不知道该怎么办。请帮助这个新手了。任何响应AP preciated。

I really don't know what to do. Please help this newbie out. Any response is appreciated.

顺便说一句,当我测试了这一点,我得到的错误消息出现在一个消息框:发送邮件失败

By the way, the error message that I get when I test this out appears in a message box: "Failure sending mail."

推荐答案

您需要在您的网站上创建一个电子邮件帐户,并使用这些凭据来发送,就像你与雅虎所做的电子邮件(这可以在您的管理来实现该网站的门户网站,但一些托管服务提供商将分别收取您的电子邮件服务)。进一步正确的SMTP服务器也应给予,这取决于你的托管服务提供商。您可以从您的托管服务提供商的信息。 127.0.0.1无论如何也不会在这里工作。

You need to create an email account in your web site and use those credentials to send the mail just as you did with yahoo (This can be done in your admin portal of the website but some hosting providers will charge you separately for the email service). Further more the correct smtp server is also should be given, that depends on your hosting provider. You can get that information from your hosting provider. 127.0.0.1 will not work here anyway.

这篇关于发送用VB code电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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