简体   繁体   中英

Not able to email the textbox data in VB.NET

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
    Try
        Dim SmtpServer As New SmtpClient()
        Dim mail As New MailMessage()
        SmtpServer.Credentials = New Net.NetworkCredential("gahlotprayank@yahoo.com", "*******")
        SmtpServer.Port = 465
        SmtpServer.Host = "smtp.mail.yahoo.com"
        mail = New MailMessage()
        mail.From = New MailAddress("gahlotprayank@yahoo.com")
        mail.To.Add("rebelme23@gmail.com")
        mail.Subject = TextBox1.Text
        mail.Body = TextBox2.Text
        SmtpServer.Send(mail)
        MsgBox("ok!")
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

i tried the above code but got the error saying "timeout" and couldn't mail the textbox data

在此处输入图片说明

The time out is likely server related and has nothing to do with your text box value. Are you sure that you have permission to use yahoo's mail server to send email?

尝试使用“ smtp.gmail.com”端口:587然后启用电子邮件帐户的“访问不太安全的应用程序”选项

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM