Question Multi Mail Sender

ArmandoMachado

New member
Joined
Nov 17, 2013
Messages
1
Location
La Ceiba, Honduras
Programming Experience
1-3
Hello there :D
I'm new to the forum and new to this VB environment(1 month of usage).

I have been working on this software: A Employees Control System.

Is it supposed to read from a barcode the employees name and that stuff, plus adding to the form the time he did this process. All this information so that in the end of the month a report is generated and it calculates his salary. If they missed a day or arrived late the salary will be reduced.

So my proyect until now has:
Reports
Barcode reader(getting one)
Database
Mail sending
and all it's respective forms

Now, i need this:
I want to send mails to one employee and to ALL the employees using the database registered mails.
I have this code for sending one mail at a time:

VB.NET:
Imports System.Net.Mail
Public Class Form4
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mensaje As New MailMessage
        Dim smtp As New SmtpClient

        Try
            If ComboBox1.SelectedItem = "smtp.live.com" Then
                smtp.Host = ComboBox1.SelectedItem
                smtp.EnableSsl = True
                smtp.Port = "587"
                smtp.Credentials = New Net.NetworkCredential(TextBox3.Text, TextBox4.Text)
                mensaje.To.Add(TextBox5.Text)
                mensaje.From = New MailAddress(TextBox3.Text)
                mensaje.Subject = TextBox1.Text
                mensaje.Body = TextBox2.Text
            Else
                If ComboBox1.SelectedItem = "smtp.gmail.com" Then
                    smtp.Host = ComboBox1.SelectedItem
                    smtp.EnableSsl = True
                    smtp.Port = "587"
                    smtp.Credentials = New Net.NetworkCredential(TextBox3.Text, TextBox4.Text)
                    mensaje.To.Add(TextBox5.Text)
                    mensaje.From = New MailAddress(TextBox3.Text)
                    mensaje.Subject = TextBox1.Text
                    mensaje.Body = TextBox2.Text
                Else
                    If ComboBox1.SelectedItem = "smtp.mail.yahoo.com" Then
                        smtp.Host = ComboBox1.SelectedItem
                        smtp.EnableSsl = True
                        smtp.Port = "587"
                        smtp.Credentials = New Net.NetworkCredential(TextBox3.Text, TextBox4.Text)
                        mensaje.To.Add(TextBox5.Text)
                        mensaje.From = New MailAddress(TextBox3.Text)
                        mensaje.Subject = TextBox1.Text
                        mensaje.Body = TextBox2.Text
                    End If
                End If
            End If

            smtp.SendAsync(mensaje, 0)
            Label3.Text = "Message Sent successfully"
            MsgBox("Mail", MsgBoxStyle.OkOnly)
        Catch ex As Exception
            MsgBox(ex.Message)
            Exit Sub
        End Try
    End Sub

I want to add a "," after each mail to send (tried and only the first mail is delivered) just like GMail and all those mailing services.

Any help or even some brief examples will be appreciated.
Thank you
 
Back
Top