Asp.net Send Bulk Emails By Using Your Gmail Account


sending Multiple emails in asp.net

In previous article I explained How to Send Email by Using Gmail ID in ASP.NET by using C# Coding. Now i show How to Send Multiple Emails by Using Gmail Account and Resolve a SMTP Server Secure Connection and Authentication 5.5.1 Required Error | The SMTP Server Requires a Secure Connection or the Client was not authenticated.

In these Tutorials, we see how to send multiple emails in asp.net, for sending multiple email we use two class's i.e MailMessage Class and SMTPClient Class these two Class are predefined class from this namespaces (System.Net.Mail Namespace).

HTML Markup : Create Bulk Email Sending Page

  <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>

C# Coding

C# : Sending Bulk Emails Code

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);
    }

Next Tutorials : How to Resove SMTPException




The SMTP SEVER Requires Secure Connection or the Client was not Authenticated the Server Response was 5.5.1 Authentication Required
0 Komentar untuk "Asp.net Send Bulk Emails By Using Your Gmail Account"

Back To Top