0 [Vb.net]Email Sender Using Smtp Client [Source Code]

By Doing This You Need :-
  • Textboxs
  • Textbox1 For Email
  • Textbox2 for Password
  • Textbox3 for Subject
  • Textbox4 for Receiver
  • Richtextbox for Message Body
  • Listbox for Attachments
  • Buttons
  • Button1 for Selecting the Attachments
  • Button2 for Send

You need to Add the OpenFiledialog from Toolbar

Our Imports :-

Imports System.Net.Mail

Let's the Coding Part :-
Click the Button1 And add this Code :-(This will Open the OpenFiledialog)


After that Add this Code :- (This will Show the Files in ListBox)

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        For Each track As String In OpenFileDialog1.FileNames
    End Sub

Click the Button2 And Add this code :-(This Will Send the Message)

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim Mail As New MailMessage
            Mail.Subject = (TextBox3.Text)
            Mail.From = New MailAddress(TextBox1.Text)
            Mail.Body = (RichTextBox1.Text)
            For counter = 0 To ListBox1.Items.Count - 1
                Dim Attach As Net.Mail.Attachment = New Net.Mail.Attachment(ListBox1.Items(counter))
            Dim SMTP As New SmtpClient("smtp.gmail.com")
            SMTP.EnableSsl = True
            SMTP.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
            SMTP.Port = 587
            MsgBox("Message Sended Successfully To " & (TextBox4.Text), MsgBoxStyle.Information, "Email SMTP Client")
        Catch ex As Exception
        End Try
    End Sub


I Used the Gmail Smtp CLient
For Live = smtp.live.com
For Aol = smtp.uk.aol.com
For Yahoo = plus.smtp.mail.yahoo.com


Put the Code in Timer1_trick Made It Email Bomber

Happy Coding

No comments:

Post a Comment