Source code:
Imports System.Web.MailPublic Class testemail1
    Inherits System.Web.UI.Page
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button#Region " Web Form Designer Generated Code "    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()    End Sub    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub#End Region    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
    End Sub    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Send("[email protected]", "[email protected]", "[email protected]", "test email", "asfsf text", MailPriority.High)
    End Sub
    Public Sub Send(ByVal FromUser As String, ByVal ToUser As String, ByVal CCUser As String, ByVal Subject As String, _
            ByVal Body As String, Optional ByVal Importance As MailPriority = MailPriority.Normal)
        Dim mailObj As New MailMessage()
        Dim smtp As SmtpMail        smtp.SmtpServer = "hqsntw3736"
        mailObj.From = FromUser
        mailObj.To = ToUser
        mailObj.Cc = CCUser        mailObj.Subject = Subject
        mailObj.Body = Body
        mailObj.BodyFormat = MailFormat.Html        mailObj.Priority = Importance
        smtp.Send(mailObj)        mailObj = Nothing
        smtp = Nothing
    End Sub
End Class

解决方案 »

  1.   

    Anybody help me? thanks!!!!
      

  2.   

    smtp.SmtpServer 正确吗?
    另外有些mailserver有限制的,可以换别的smtpserver试试看
      

  3.   

    I use my own computer. And the smtp server has run.
    I have used "localhost" but it also encouter the same problem.
    thanks!
      

  4.   

    Oh, my god!
    I'v got it.
    I need setting the smtp server first.
    Here are the steps, I did.1. In IIS right-click on the Default SMTP Virtual Server and select Properties. 
    2. In the Properties dialog box, selec the Access tab. 
    3. Click on the Relay button. 
    4. In the Relay Restrictions dialog box, select the Allow except the list below radio button.