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

  • Home
  • SEARCH
  • 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 8284651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:11:06+00:00 2026-06-08T11:11:06+00:00

May I know how to send email based on gridview column containing email addresses?

  • 0

May I know how to send email based on gridview column containing email addresses?
I am currently using asp.net and c#. I’m also currently using smtp gmail for the email.

Currently, I had a gridview1 which contain customers (email, name, accountNo) that had bounced cheque, however I wish to send an standard email, to all these customers upon clicking a button. May I know how should i go about it? Their email is stored in database and will be shown on gridview.

   private void SendEMail(MailMessage mail)
{
    SmtpClient client = new SmtpClient();
    client.Host = "smtp.gmail.com";
    client.Port = 587;
    client.EnableSsl = true;
    client.Credentials = new System.Net.NetworkCredential("@gmail.com", "password");

    try
    {
        client.Send(mail);
    }
    catch (Exception ex)
    {
        Console.WriteLine("{0} Exception caught.", ex);
    }

enter image description here

  • 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-08T11:11:08+00:00Added an answer on June 8, 2026 at 11:11 am

    The easiest would be loop through the dataset that you have bound to grid view. But since you have asked about gridview, here is how you can loop through gridview rows

    On button_click write this

    string email = "";
    foreach (GridViewRow item in GridView1.Rows)
    {
          //considering 1st column contains email address
          //if not, replace it with correct index
          email =  item.Cells[0].Text;
          //code to send email
    
    }
    

    UPDATE 2

    Updating my code to use your sendEmail function

    public void button_click(object sender, EventArgs e)
    {
        string email = "";
        foreach (GridViewRow item in GridView1.Rows)
        {
    
              //if not, replace it with correct index
              email =  item.Cells[4].Text;
              //code to send email
             //reciever email add
             MailAddress to = new MailAddress(email);
             //sender email address
             MailAddress from = new MailAddress("your@email");
    
            MailMessage msg = new MailMessage();
            //use reason shown in grid
            msg.Subject = item.Cells[3].Text;
    
            //you can similar extract FName, LName, Account number from grid
            // and use it in your message body
            //Keep your message body like 
            str email_msg = "Dear {0} {1}, Your cheque for account number {2} bounced because of    the reason {3}";
            msg = String.Format(email_msg , item.Cells[0].Text,item.Cells[1].Text,item.Cells[2].Text,item.Cells[3].Text);
            msg.Body = email_msg ;
            msg.From = from;
            msg.To.Add(to);
    
            SendEMail(msg);
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my web app (ASP.NET MVC), I send an email using the following: MailMessage
I am using System.Net.Mail to to send mail. I do not know the type/version
You may know this recommendation from Microsoft about the use of exceptions in .NET:
I have problem to send array from database via email. I´m sure may people
Problem: I send out an email (using phpmailer and sendmail) which has a complex
I know how to send email...how do I download my email? I've been searching
You may know the scriptaculous SlideUp effect . Well, It slides up a div
So as you may know, arrays in C# implement IList<T> , among other interfaces.
As you may know, Silverlight 3 doesn't support IMultiValueConverter and... I badly need it.
As some of you may know, use of the LIMIT keyword in MySQL does

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.