locked
[HelpRequest]Failure sending mail.(SMTP) RRS feed

  • Question

  • Hello, I'm just learning and I tried to make something, in this case a email sender, both of the emails are owned by me.

    Whenever I debug, I get an error afterwards: Failure sending mail. Please reply if more information is required.

    Private Sub sendmail()
            Dim Mail As New MailMessage
            Mail.Subject = "LSPD Recruitment Status"
            Mail.To.Add("crystallifeapplications@gmail.com")
            Mail.From = New MailAddress("lspdtests06@gmail.com")
            Mail.Body = LSPD
            Dim SMTP As New SmtpClient("smpt.hotmail.com")
            SMTP.EnableSsl = True
            SMTPServer.Credentials = New System.Net.NetworkCredential("lspdtests06@gmail.com", "*******")
            SMTP.Port = "587"
            SMTP.Send(Mail)

    Thursday, July 25, 2013 1:39 AM

Answers

  • Thank you for posting the code however it didn't work.

    I got twelve errors.

    I'm running on Visual Studio 2010.

    And you've also posted VB code to a C# forum. Bob gave you an answer in C# ... probably why you got errors. Try using this online converter:

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    If you wish, I can move this thread to the VB forum, but I won't bother if you can get Bob's code converted to VB with the converter link I posted. Let me know ...


    ~~Bonnie Berent DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com


    • Edited by BonnieBMVP Monday, July 29, 2013 12:42 AM additional clarification
    • Marked as answer by Caillen Thursday, August 1, 2013 1:18 PM
    Sunday, July 28, 2013 11:53 PM

All replies

  • Hi RobertL,

    You should change your SmtpClient to "smtp.gmail.com", you can also check the sample below.

                using (var client = new SmtpClient("smtp.gmail.com", 587))
                {
                    client.Credentials = new NetworkCredential("xxx@gmail.com", "password");
                    var mail = new MailMessage();
                    mail.From = new MailAddress("xxx@gmail.com");
                    mail.To.Add("xx@live.com");
                    mail.Subject = "Test mail";
                    mail.Body = "test body";
                    client.EnableSsl = true;
                    client.Send(mail);
                }  


    Bob Shen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 26, 2013 8:35 AM
  • Thank you for posting the code however it didn't work.

    I got twelve errors.

    I'm running on Visual Studio 2010.

    Sunday, July 28, 2013 11:34 PM
  • Thank you for posting the code however it didn't work.

    I got twelve errors.

    I'm running on Visual Studio 2010.

    And you've also posted VB code to a C# forum. Bob gave you an answer in C# ... probably why you got errors. Try using this online converter:

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    If you wish, I can move this thread to the VB forum, but I won't bother if you can get Bob's code converted to VB with the converter link I posted. Let me know ...


    ~~Bonnie Berent DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com


    • Edited by BonnieBMVP Monday, July 29, 2013 12:42 AM additional clarification
    • Marked as answer by Caillen Thursday, August 1, 2013 1:18 PM
    Sunday, July 28, 2013 11:53 PM