Here I have created sample that will help you out.
I referred below articles
Send mail to multiple Users (Recipients) in ASP.Net using C# and VB.Net
HTML
<div>
<script type="text/javascript" src='http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js'></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"
charset="utf-8"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"
type="text/javascript" charset="utf-8"></script>
<script src="JS/tag-it.js" type="text/javascript"></script>
<link href="css/jquery.tagit.css" rel="stylesheet" type="text/css">
<link href="CSS/tagit.ui-zendesk.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
$("#myTags").tagit({
autocomplete: {
delay: 0,
minLength: 2,
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/Default.aspx/GetEmails") %>',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item,
val: item
}
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
}
}
});
});
function GetSelectedEmails() {
$('[id*=hfSelectedEmails]').val($("#myTags").tagit("assignedTags"));
}
</script>
<div>
<table width="400px">
<tr>
<td>
Email:
</td>
<td>
<ul id="myTags">
</ul>
</td>
</tr>
<tr>
<td>
Subject :
</td>
<td>
<asp:TextBox ID="txtSubject" runat="server" />
</td>
</tr>
<tr>
<td>
Body :
</td>
<td>
<asp:TextBox ID="txtBody" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Button1" Text="Send Email" runat="server" OnClientClick="GetSelectedEmails()"
OnClick="SendBulkEmail" />
<input type="hidden" id="hfSelectedEmails" runat="server" />
</td>
</tr>
</table>
</div>
</div>
C#
[WebMethod]
public static string[] GetEmails(string prefix)
{
List<string> customers = new List<string>();
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "SELECT [Email] FROM [tbUserRgistrsn] where Email like @SearchText + '%'";
cmd.Parameters.AddWithValue("@SearchText", prefix);
cmd.Connection = conn;
conn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
customers.Add(sdr["Email"].ToString());
}
}
conn.Close();
}
}
return customers.ToArray();
}
protected void SendBulkEmail(object sender, EventArgs e)
{
string subject = txtSubject.Text.Trim();
string body = txtBody.Text.Trim();
Parallel.ForEach(hfSelectedEmails.Value.Split(','), email =>
{
SendEmail(email, subject, body);
});
}
private bool SendEmail(string recipient, string subject, string body)
{
MailMessage mm = new MailMessage("sender@gmail.com", recipient);
mm.Subject = subject;
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential();
NetworkCred.UserName = "sender@gmail.com";
NetworkCred.Password = "<password>";
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
return true;
}
VB
<WebMethod> _
Public Shared Function GetEmails(prefix As String) As String()
Dim customers As New List(Of String)()
Using conn As New SqlConnection()
conn.ConnectionString = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using cmd As New SqlCommand()
cmd.CommandText = "SELECT [Email] FROM [tbUserRgistrsn] where Email like @SearchText + '%'"
cmd.Parameters.AddWithValue("@SearchText", prefix)
cmd.Connection = conn
conn.Open()
Using sdr As SqlDataReader = cmd.ExecuteReader()
While sdr.Read()
customers.Add(sdr("Email").ToString())
End While
End Using
conn.Close()
End Using
End Using
Return customers.ToArray()
End Function
Protected Sub SendBulkEmail(sender As Object, e As EventArgs)
Dim subject As String = txtSubject.Text.Trim()
Dim body As String = txtBody.Text.Trim()
Parallel.ForEach(hfSelectedEmails.Value.Split(","C), Function(email)
SendEmail(email, subject, body)
End Function)
End Sub
Private Function SendEmail(recipient As String, subject As String, body As String) As Boolean
Dim mm As New MailMessage("sender@gmail.com", recipient)
mm.Subject = subject
mm.Body = body
mm.IsBodyHtml = True
Dim smtp As New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.EnableSsl = True
Dim NetworkCred As New NetworkCredential()
NetworkCred.UserName = "sender@gmail.com"
NetworkCred.Password = "<password>"
smtp.UseDefaultCredentials = True
smtp.Credentials = NetworkCred
smtp.Port = 587
smtp.Send(mm)
Return True
End Function
Screenshot