简体   繁体   English

无法通过电子邮件发送VB.NET中的文本框数据

[英]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? 您确定您有权使用yahoo的邮件服务器发送电子邮件吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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