Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8729687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:52:41+00:00 2026-06-13T08:52:41+00:00

i am trying to send all the email listed in my GridView but for

  • 0

i am trying to send all the email listed in my GridView but for somereason, the email does not get sent out. I am suspecting my Send function (smtpClient.Send(mailMessage); is not working or i am missing something. Pls help as i have spent so many hours on figuring out this. thanks

protected void chkAll_CheckedChanged(object sender, EventArgs e) 
{ 
    foreach(GridViewRow gr in GridView1.Rows) 
    { 
        CheckBox cb = (CheckBox)gr.FindControl("chkItem"); 
        if(((CheckBox)sender).Checked) 
            cb.Checked = true; 
        else 
             cb.Checked = false; 
    } 
} 

protected void Button3_Click(object sender, EventArgs e) 
{ 
    StringBuilder sb = new StringBuilder(); 

    foreach(GridViewRow gr in GridView1.Rows) 
    { 
        CheckBox cb = (CheckBox)gr.FindControl("chkItem"); 
        if(cb.Checked) 
        { 
            sb.Append(GridView1.DataKeys[gr.RowIndex]["Email"].ToString()); 
            sb.Append(","); 
        } 
    } 

    //Create instance of main mail message class. 
    System.Net.Mail.MailMessage mailMessage=new System.Net.Mail.MailMessage(); 

        mailMessage.From = new System.Net.Mail.MailAddress(
                   System.Configuration.ConfigurationManager
                                 .AppSettings["fromEmailAddress"]); 

        mailMessage.Priority = System.Net.Mail.MailPriority.High; 
        //Text/HTML 
        mailMessage.IsBodyHtml = false; 
        mailMessage.Body = "Hello, here is new email"; 
        mailMessage.Subject = "RCA APPROVAL IS REQUIRED"; 

        System.Net.Mail.SmtpClient smtpClient=new System.Net.Mail.SmtpClient();

        try 
        { 
            smtpClient.Send(mailMessage); 

            Response.Write("<B>Email Has been sent successfully.</B>"); 
        } 
        catch (Exception ex) 
        { 
            Response.Write(ex.Message); 
        } 
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:52:42+00:00Added an answer on June 13, 2026 at 8:52 am

    You need to set the To address for the MailMessage

    You might want to do it like:

    protected void Button3_Click(object sender, EventArgs e) 
    {
        MailMessage mailMessage=new MailMessage(); 
    
        foreach(GridViewRow gr in GridView1.Rows) 
        { 
            CheckBox cb = (CheckBox)gr.FindControl("chkItem"); 
            if(cb.Checked) 
            { 
                //sb.Append(GridView1.DataKeys[gr.RowIndex]["Email"].ToString()); 
                //sb.Append(","); 
    
                //SETUP THE EMAIL ADDRESSES TO WHICH YOU WANT TO SEND EMAIL
                mailMessage.To.Add(new MailAddress(
                         GridView1.DataKeys[gr.RowIndex]["Email"].ToString()));
            } 
        } 
    

    Moreover if your SMTP server needs authentication you need to provide the Credentials also. Or you can put all the settings into <system.net><mailSettings> tag in web.config as shown here by none other than the mightly Scott Gu

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to use PHP Mail function to send myself an email of all
I am trying to send an email with PHP but I get a weird
Trying to send a PHP email the easy way but I cannot work out
I'm trying to load in predefined email messages to send out -- my question
I'm trying to programmatically send an email of all of the dll files and
Im trying to send an email to multiple addresses, so I wrote function that
I'm trying to send out a Plain/HTML multipart email out and I'm currently using
Am trying to send SMS using PHP file. All email attributes are included on
I'm trying to send an email via asp.net mvc2, and all works well on
I've been trying to send an email from my magento module but for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.