Send Multiple Email in Asp.net


In this articles i'm going to show you how to send multiple emails in asp.net by using c# coding. Email address should be separated by using comma's to achieve for sending multiple email in asp.net. In this article i'm going to show you how to achieve this.

Description :


In this articles i'm going to show you how to send multiple emails in asp.net by using c# coding. Email address should be separated by using comma's to achieve sending multiple email in asp.net.
How to Send Multiple Email in asp.net by using C# coding

HTML MarkUp :



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Registration.aspx.cs" Inherits="Registration" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td colspan="3" style="width:50px;">
</td>
<td>
<table>
<tr>
<th colspan="2" align="left">Multiple Mail Sending</th>
</tr>
<tr>
<td style="width:20px;">To : </td><td><asp:TextBox ID="txt_mul_mail" runat="server" Width="310px"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="txt_mul_msg" runat="server" TextMode="MultiLine" Width="336px"
Height="199px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Btn_mul_mail" runat="server" Text="Send Multiple Mail"
onclick="Btn_mul_mail_Click" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

C# Coding for Send Multiple Email :



protected void Btn_mul_mail_Click(object sender, EventArgs e)
{
string to_email_id = txt_mul_mail.Text;
MailMessage ms = new MailMessage();
ms.From = new MailAddress("Your Gmail ID");
ms.Subject = "Testing Sending Multiple Mail at a Time";
ms.Body = txt_mul_msg.Text;
string[] multiple_to_sending_mail = to_email_id.Split(',');
foreach (string to_multiple_email in multiple_to_sending_mail)
{
ms.To.Add(to_multiple_email);
}
ms.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.Credentials = new System.Net.NetworkCredential("Your Gmail ID", "Your Gmail ID Password");
smtp.EnableSsl = true;
smtp.Send(ms);
}


Comments

Author: Gaurav Kumar Arora18 Jan 2016 Member Level: Gold   Points : 0

Do you mean Bulk emailing?

Author: srikanth19 Jan 2016 Member Level: Silver   Points : 0

Yes



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: