Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Sending mail (GMAIL)

Hi guys,

I need your help. My problem is that why I can't send an email to gmail? :(

Code
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Try
            Dim Smtp_Server As New SmtpClient
            Dim e_mail As New MailMessage()
            Smtp_Server.UseDefaultCredentials = False
            Smtp_Server.Credentials = New Net.NetworkCredential("[email protected]", "password")
            Smtp_Server.Port = 587
            Smtp_Server.EnableSsl = True
            Smtp_Server.Host = "smtp.gmail.com"

            e_mail = New MailMessage()
            e_mail.From = New MailAddress(txtFrom.Text)
            e_mail.To.Add(txtTo.Text)
            e_mail.Subject = "Email Sending"
            e_mail.IsBodyHtml = False
            e_mail.Body = txtMessage.Text
            Smtp_Server.Send(e_mail)
            MsgBox("Mail Sent")

        Catch error_t As Exception
            MsgBox(error_t.ToString)
        End Try

    End Sub

please help.

Thanks in advance
Probably because you don't own [email protected]. Kidding. I think there's more to be done to send through them. I know when I was making an SMTP mailer, I had to send like 4 times for the message to go through once (I don't know and never figured out why.)
(Nov 20, 2015 11:55 AM)twobol2002 Wrote:  Hi guys,

I need your help. My problem is that why I can't send an email to gmail? :(

Code
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Try
            Dim Smtp_Server As New SmtpClient
            Dim e_mail As New MailMessage()
            Smtp_Server.UseDefaultCredentials = False
            Smtp_Server.Credentials = New Net.NetworkCredential("[email protected]", "password")
            Smtp_Server.Port = 587
            Smtp_Server.EnableSsl = True
            Smtp_Server.Host = "smtp.gmail.com"

            e_mail = New MailMessage()
            e_mail.From = New MailAddress(txtFrom.Text)
            e_mail.To.Add(txtTo.Text)
            e_mail.Subject = "Email Sending"
            e_mail.IsBodyHtml = False
            e_mail.Body = txtMessage.Text
            Smtp_Server.Send(e_mail)
            MsgBox("Mail Sent")

        Catch error_t As Exception
            MsgBox(error_t.ToString)
        End Try

    End Sub

please help.

Thanks in advance
i don't know if this code can help you, it is a bit hard to know what is wrong? you got a error or something? i remember i had something simular in the past and this is the code that only worked to me. anyways you need to turn off some security on ur gmail to make it work. Hope it helps

Dim mymailmessage As New MailMessage()
Try
mymailmessage.From = New MailAddress("[email protected]")
mymailmessage.To.Add("[email protected]")
mymailmessage.Subject = ""
mymailmessage.Body = ": "
Dim SMPT As New SmtpClient("smtp.gmail.com")
SMPT.Port = 587
SMPT.EnableSsl = True
SMPT.Credentials = New System.Net.NetworkCredential("[email protected]", "password")
SMPT.Send(mymailmessage)




Catch ex As Exception

End Try
rednas, your message did not contain anything. You just copy pasted a quote.
it says:

"The SMTP server requires a secure connection or the client was not authenticated."
(Nov 20, 2015 12:09 PM)twobol2002 Wrote:  it says:

"The SMTP server requires a secure connection or the client was not authenticated."
you tried the code i posted? anyways you have to go to security in ur gmail and change the security to low or something to make it possible for ur application to access it.

(Nov 20, 2015 12:09 PM)twobol2002 Wrote:  it says:

"The SMTP server requires a secure connection or the client was not authenticated."
and i think this error mean that it has something with the security with ur gmail todo. so nothing should be wrong with the code. so just change the security and it should work:)
you have to allow un secure apps through your email account.
its what almost every email carrier is doing now.
thanks guys for your help... i got it working by changing the settings in my gmail.... :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by splinter1Dec 27, 2021 09:17 AM 1 133 Dec 27, 2021 09:17 AM
Last Post: oje28830
[C#] by kanare007Jun 23, 2016 02:36 AM 7 484 Jun 23, 2016 02:36 AM
Last Post: kanare007
[Java] by Null.May 31, 2016 08:47 PM 5 538 May 31, 2016 08:47 PM
Last Post: JIM NASIUM'S GYMNASIUM