如何配置 smtp 设置

发布于 2024-11-16 01:43:52 字数 2401 浏览 2 评论 0原文

Imports System.Net.Mail

Partial Class ContactUs
    Inherits System.Web.UI.Page
    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Dim username = User.Identity.Name.ToString
        Response.Redirect("~/ViewCart_aspx/ViewCart.aspx?userID=" & username)
    End Sub
    Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
        If txtComments.Text.Length > 200 Then
            args.IsValid = False
        Else
            args.IsValid = True
        End If
    End Sub

    Protected Sub WizardStep3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles WizardStep3.Load
        lblName.text = txtName.Text
        lblEmail.Text = txtEmail.Text
        lblComments.Text = txtComments.Text
        lblRating.Text = txtRatings.Text
    End Sub
    Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
        SendMail(txtEmail.Text, txtComments.Text)
        'MsgBox("Feedback Sent")
        Response.Redirect("homepage_aspx/homepage.aspx")

    End Sub

    Private Sub SendMail(ByVal from As String, ByVal body As String)

        Dim mMailSettings As System.Net.Configuration.MailSettingsSectionGroup

        Dim mPort As Integer = mMailSettings.Smtp.Network.Port
        Dim mHost As String = mMailSettings.Smtp.Network.Host
        Dim mPassword As String = mMailSettings.Smtp.Network.Password
        Dim mUsername As String = mMailSettings.Smtp.Network.UserName
        'Dim mailServerName As String = "smtp.tricedeals.com"
        'Dim message As MailMessage = New MailMessage(from, "[email protected]", "feedback", body)
        'Dim mailClient As SmtpClient = New SmtpClient

        'mailClient.Host = mailServerName
        'mailClient.Send(message)
        'message.Dispose()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
    End Sub
End Class

我的 smtp 设置有什么问题?我无法发送电子邮件。请帮助我。

Imports System.Net.Mail

Partial Class ContactUs
    Inherits System.Web.UI.Page
    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Dim username = User.Identity.Name.ToString
        Response.Redirect("~/ViewCart_aspx/ViewCart.aspx?userID=" & username)
    End Sub
    Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
        If txtComments.Text.Length > 200 Then
            args.IsValid = False
        Else
            args.IsValid = True
        End If
    End Sub

    Protected Sub WizardStep3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles WizardStep3.Load
        lblName.text = txtName.Text
        lblEmail.Text = txtEmail.Text
        lblComments.Text = txtComments.Text
        lblRating.Text = txtRatings.Text
    End Sub
    Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
        SendMail(txtEmail.Text, txtComments.Text)
        'MsgBox("Feedback Sent")
        Response.Redirect("homepage_aspx/homepage.aspx")

    End Sub

    Private Sub SendMail(ByVal from As String, ByVal body As String)

        Dim mMailSettings As System.Net.Configuration.MailSettingsSectionGroup

        Dim mPort As Integer = mMailSettings.Smtp.Network.Port
        Dim mHost As String = mMailSettings.Smtp.Network.Host
        Dim mPassword As String = mMailSettings.Smtp.Network.Password
        Dim mUsername As String = mMailSettings.Smtp.Network.UserName
        'Dim mailServerName As String = "smtp.tricedeals.com"
        'Dim message As MailMessage = New MailMessage(from, "[email protected]", "feedback", body)
        'Dim mailClient As SmtpClient = New SmtpClient

        'mailClient.Host = mailServerName
        'mailClient.Send(message)
        'message.Dispose()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
    End Sub
End Class

what is wrong with my smtp settings??i cant send emails.please help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁客 2024-11-23 01:43:52

您无法发送电子邮件,因为发送命令已被注释掉。因为您没有提供更多详细信息或更好的解释或异常消息,这是我唯一可以假设的事情。

you can't send email because the send command is commented out. since you don't give more details or better explanation or exception message that's the only thing I can assume.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文