Cara Mengirim Email Dengan VB 2010



Pada Posting saya kali ini yaitu bagaimana cara membuat program pengirim email dengan menggunakan VB 2010.

Buat satu Project
Tambahkan Form (Button)

Tuliskan Code Berikut :
=======================================================================
Imports System.Net.Mail
Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mail As New MailMessage()
        Dim SmtpServer As New SmtpClient("smtp.gmail.com")
        mail.From = New MailAddress("almtemailente")
        mail.[To].Add("alamatemailygdituju")
        mail.Subject = "subject email"
        mail.Body = "isiemail"

        Dim attachment As System.Net.Mail.Attachment
        attachment = New System.Net.Mail.Attachment("path attachment file") "Path attachment File Boleh dipakai boleh tidak
        mail.Attachments.Add(attachment)

        SmtpServer.Port = 587
        SmtpServer.Credentials = New System.Net.NetworkCredential("alamatemail", "password")
        SmtpServer.EnableSsl = True

        SmtpServer.Send(mail)
        MessageBox.Show("mail Send")
    End Sub

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

    End Sub
End Class

=======================================================================


Ada Kopikah.... Kawam.....  ^_^

Bagi Dommm...












Previous
Next Post »
Thanks for your comment