About my Blog

But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain

Rabu, 05 September 2012

Membuat Program Mengirim Email dengan VB.NET


kali ini saya mencoba membagi pengetahuan tentang vb.net. Kita sering mengirim surat dengan menggunakan email, nahh sekarang saya akan membagi bagaimana membuat program sederhana VB.NET untuk mengirim email kitagunakan GMAIL . 

Susun tampilan form seperti gambar dibawah ini : 


dan masukan Sorcecode  :

Imports System.Net.Mail
Public Class Form1

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub

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

        Dim smtpServer As New SmtpClient()
        Dim mail As New MailMessage
        smtpServer.Credentials = New Net.NetworkCredential(TextBox1.Text & "@gmail.com", TextBox2.Text)
        'smtpServer.Credentials = New Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
        smtpServer.Port = 587
        smtpServer.Host = "smtp.gmail.com"
        smtpServer.EnableSsl = True
        mail.From = New MailAddress(TextBox1.Text & "@gmail.com")
        'mail.From = New MailAddress(TextBox1.Text)
        mail.To.Add(TextBox3.Text)
        mail.Subject = TextBox4.Text
        mail.Body = TextBox5.Text()
        Try
            smtpServer.Send(mail)
            MsgBox("mail is sent", MsgBoxStyle.OkOnly, "Report")
        Catch ex As Exception
            MsgBox(ex.Message())
        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox5.Clear()
        TextBox5.Focus()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class


jika ingin mendapatkan SorceCode langsung klik disini :)


0 komentar:

Posting Komentar