asp.net设置电子邮件 [英] asp.net Setting up email

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

问题描述

唉,我的经验已经到头并请求帮助。到目前为止,我已经跟着从这篇文章 http://www.4guysfromrolla.com/的说明WEBTECH / 080801-1.shtml 。我唯一​​的问题是,它编译罚款,但没有电子邮件到达。我有一种感觉它是这离我而去明显的原因。

Alas, my experience has reached an end and request help. So far I've followed the instructions from this article http://www.4guysfromrolla.com/webtech/080801-1.shtml . My only problem is It compiles fine but no email arrives. I have a feeling it's for obvious reasons which escape me.

这是我的aspx.vb page.................................................................................................................

This is my aspx.vb page.................................................................................................................

Imports System.Web.Mail

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

    Const ToAddress As String = "paul.ramirez@att.net"
    Dim objMM As New MailMessage("paramireze@gmail.com", ToAddress)
    Dim smtp As New SmtpClient
    objMM.IsBodyHtml = False
    objMM.Priority = MailPriority.Normal
    objMM.Subject = "Hello there!"
    objMM.Body = "Hi!" & vbCrLf & vbCrLf & "How are you doing?"
    smtp.Send(objMM)
end sub

..........................................................................................................................................................

..........................................................................................................................................................

我的aspx页面包含以下... W / O括号
<%@导入命名空间=System.Web.Mail%GT;

my aspx page contains the following ...w/o the parenthesis (<%@Import Namespace="System.Web.Mail" %>)

web.config文件如下(遗憾的是它不会大于小于符号显示。

The web.config file is as follows(unfortunately it won't display with greater than less than symbols.

<configSections>
  <system.net>
    <mailSettings>
      <smtp>
        <network host="relay-hosting.secureserver.net" port="25">
      </smtp>
    </mailSettings>
  </system.net>
</configSections>

在godaddy.com的人告诉我,我需要的唯一信息是relayServer主机名是relay-hosting.secureserver.net和不要求用户名和密码。

The people at godaddy.com told me that the only information I needed was the relayServer host name which is relay-hosting.secureserver.net and username and password weren't required.

感谢您的帮助。

推荐答案

我觉得这是你的问题。从80端口更改邮件服务器端口到端口25在web.config

I think that is your problem. Change the mail server port from port 80 to port 25 in the web.config

尝试使用code的此块:

Try using this block of code:

Dim objMailMessage As New System.Net.Mail.MailMessage 

With objMailMessage 
    .IsBodyHtml = False 
    .From = New MailAddress("fromaddress@youremailaccount.com")   
    .To.Add("destinationaddress@whoever.com") .Subject = "Your Subject" 
    .Body = "Body Text" 
End With 

Dim objSMTPClient As New System.Net.Mail.SmtpClient("relay-hosting.secureserver.net", 25) 
objSMTPClient.Credentials = CredentialCache.DefaultNetworkCredentials
objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.Network 
objSMTPClient.Send(objMailMessage)

下面是线程和其他一些例子为好。它还听起来像有一个GoDaddy的设置地方,但我不记得不必在我结束改变任何东西。

Here is the thread and some other examples as well. It also sounds like there is a godaddy setting somewhere, but I don't remember having to change anything on my end.

http://forums.asp.net/t/939893.aspx

这篇关于asp.net设置电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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