Hi All,

i have a homework of programming (vb.net) that need create send email function by using vb.net.. I already find a bunch of solution in google, but still i didn't work..

below is my source code..

source code:

Imports System.net.Mail
Public Class Form1
Sub SendOneEmail()
        Dim SendTo, strSubject, strMessage As String
            SendTo = "email@gmail.com"
            strSubject = "Yeah"
            strMessage = "Yeah"
            SendEmail(strMessage, SendTo, strSubject)
        Catch ex As Exception
            MessageBox.Show(ex.Message & "in SendOneEmail")
        End Try
End Sub

Public Sub SendEMail(ByVal Message As String, ByVal EMailAddress As String, ByVal Subject As String)
        Dim EMail As New System.Net.Mail.MailMessage
        Dim SMTPServer As New System.Net.Mail.SmtpClient
        Dim Authentication As New Net.NetworkCredential("email@gmail.com", "password")

        EMail.From = New System.Net.Mail.MailAddress("email@gmail.com")
        EMail.Body = Message
        EMail.Subject = Subject

        SMTPServer.Timeout = 100000
        SMTPServer.Host = "smtp.gmail.com"
        SMTPServer.Port = 25
        SMTPServer.Credentials = Authentication

End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class

actually i already find a bunch of solution and source code.. i dunno where is the problem.. another friend of mine said perhaps i have a problem with my internet connection... (i don't think so)

And i search in google.. there is the URL that said i need to change the setting of POP/IMAP in my gmail account..

And i also don't know what port that i should use XD

can you figure out what's the problem??

Thank you ~~~:confused: ORZ

Done Already.. Thanks
the result is there is no problem in port or anything..
i just need the password for smtp


OK... I Will Answer My Question. The Program below is work:

Imports System.IO
Imports System.Net.Mail

Public Class frmSendEmail

    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
        Dim ESen As New Net.Mail.MailAddress(txtFrom.Text, "rnd") 'Sender
        Dim ERec As New Net.Mail.MailAddress(txtTo.Text) 'Recipient

        Dim stream As New Net.Mail.SmtpClient("smtp.gmail.com", 465) 'Host, port
        Dim Credentials As New System.Net.NetworkCredential("****", "****") 'Username, Password

        stream.Credentials = Credentials


            Dim message As New Net.Mail.MailMessage(ESen, ERec) 'Email message
            message.Subject = txtSubject.Text
            message.Body = txtMessages.Text


        Catch ex As Exception
            txtMessages.Text = ex.Message

            stream = Nothing
            Credentials = Nothing
            ESen = Nothing
            ERec = Nothing

        End Try

    End Sub

End Class

My Problem Last time is i don't know username and password for smtp..
and now i already get it..

Case Closed !! <Detective Conan>

This article has been dead for over six months. Start a new discussion instead.