0

So I'm making a Program to Start/Restart/Stop and running commands from the Console for my Server.
Now when someone uses the console, I want to be alerted of it on my Mail.
I am using Visual Studio 2010.
This is my Code:

        Dim mail As New MailMessage
        Dim smtp As New SmtpClient
        Try
            mail.From = New MailAddress("mailwheretobealerted@testmail.com")

            mail.To.Add("mailwheretobealerted@testmail.com")

            mail.Subject = ("Text")


            mail.Body = ("Some other Text")

            Dim s As New SmtpClient("smtp.gmail.com")

            s.Port = 587

            s.EnableSsl = True

            s.Credentials = New Net.NetworkCredential("Mailthatalerts@testmail.com", "password")

            s.Send(mail)

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

Of course I hidden some of my personal informations but this is it, when I'm clicking on the button, I get THIS error:

The SMTP Server requires a secure connection or the client was not authenticated.
The server response was: 5.5.1 Authentification required. Learn more at

I have another Program that does the same on VB 2008, and it works fine.
Any help would be very appreciated.
Thank you in advance!

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by poojavb
0
    Dim SmtpServer As New SmtpClient()
    Dim mail As New MailMessage()
    SmtpServer.Credentials = New Net.NetworkCredential("abc.def@gmail.com", "abc123def")
    SmtpServer.Port = 25
    SmtpServer.Host = "mail.google.com"
    mail = New MailMessage()
    mail.From = New MailAddress("abc.def@gmail.com")
    mail.To.Add("abc.ljk@gmail.com")
    mail.Subject = "Testing"
    mail.Body = subject
    SmtpServer.Send(mail)
    MsgBox("mail sent sucessfully")

Ur connections are correct...try putting ur credentials at first...the above code works for me.....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.