locked
Sending Email Failure RRS feed

  • Question

  • User988538322 posted

    Hi

    Hope all you are fine. 

    I want to send email from vb.net 2008. All of my code is correct but i don't know why the message comes "Mail Sending Failure"

    here is my code

    Imports System.Net.Mail
    
    Public Class frmMailing
        Dim SmtpServer As New SmtpClient()
        Dim mail As New MailMessage()
    
        Sub sendEmail()
            Try
                SmtpServer.Credentials = New Net.NetworkCredential(Trim("myemail@yahoo.com"), Trim("MyPassword"))
                SmtpServer.Port = "995"
                SmtpServer.Host = "smtp.mail.yahoo.com"
                mail.From = New MailAddress(Trim("myemail@yahoo.com"))
                mail.To.Add(Trim("ToEmail@hotmail.com"))
                mail.Subject = Trim("Hi")
                mail.Body = Trim("Hi")
                SmtpServer.Send(mail)
                MsgBox("Mail Sent", MsgBoxStyle.Information, "Mail Sent")
            Catch ex As Exception
                MsgBox(ex.Message.ToString)
            End Try
    
        End Sub
    
        Private Sub frmMailing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            sendEmail()
        End Sub
    End Class

    Please help me

    Saturday, August 4, 2012 9:07 AM

Answers

All replies

  • User-1315512054 posted

    Hello,

    You could check if you can to send email manually trough this SMTP server (enter in command promt "telnet smtp.mail.yahoo.com:995" and after that enter your credentials). You could also check at how to send email in ASP.NET.

    Regards

    Saturday, August 4, 2012 12:07 PM
  • User1771049139 posted

    I think you are using wrong smtp Port.

    It should be as follows :

    Outgoing mail server (SMTP) settings:

    • SMTP server: smtp.mail.yahoo.com
    • Use SSL
    • Port: 465
    • Use authentication

    You can also check following URL :

    Yahoo Help

    Saturday, August 4, 2012 10:35 PM
  • User988538322 posted

    i have change these settings but the error is same. Here is my Code

    Imports System.Net.Mail
    
    Public Class frmMailing
        Dim SmtpServer As New SmtpClient()
        Dim mail As New MailMessage()
    
        Sub sendEmail()
            Try
                SmtpServer.Host = "smtp.mail.yahoo.com"
                SmtpServer.Port = "465"
                SmtpServer.Credentials = New Net.NetworkCredential(Trim("myemail@yahoo.com"), Trim("MyPassword"))
                mail.From = New MailAddress(Trim("myemail@yahoo.com"))
                mail.To.Add(Trim("ToEmail@hotmail.com"))
                mail.Subject = Trim("Hi")
                mail.Body = Trim("Hi")
                SmtpServer.Send(mail)
                MsgBox("Mail Sent", MsgBoxStyle.Information, "Mail Sent")
            Catch ex As Exception
                MsgBox(ex.Message.ToString)
            End Try
    
        End Sub
    
        Private Sub frmMailing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            sendEmail()
        End Sub
    End Class


    can you send me your code?

    Sunday, August 5, 2012 7:52 PM
  • User1954304945 posted

    Hi, please set “EnableSsl” to true:

    SmtpServer.EnableSsl = true;  

    Additionally, please make sure your “mailSettings”  is “web.config” is correct, please refer to the example on the following site:

    http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 6, 2012 1:40 AM