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 9033125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:09:09+00:00 2026-06-16T08:09:09+00:00

I am a new ASP.NET developer and I am developing a simple registration system.

  • 0

I am a new ASP.NET developer and I am developing a simple registration system. I am trying now to let the system administrator being able to send reminders to the registered users before the start date of the event. All the avaliable events will be listed in a GridView with a button for sending reminders to the registered users in that event.
For your information, I have the following database design:

Employees Table: NetID, Name
Events Table: ID, Title
BookingDetails Table: BookingID, EventID, NetID

**Please note that NetID is the username of the employee

ASP.NET Code:

<asp:GridView ID="ListOfAvailableEvents_GrivView" runat="server" 
            AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333"
                    GridLines="None" AllowPaging="True">
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" CssClass="generaltext" />
                    <Columns>
                        <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                        <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                        <asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" />
                        <asp:BoundField DataField="StartDateTime" HeaderText="Start Date & Time" SortExpression="StartDateTime" />
                        <asp:BoundField DataField="EndDateTime" HeaderText="End Date & Time" SortExpression="EndDateTime" />
                        <asp:BoundField DataField="NumberOfSeats" HeaderText="Number of Seats" SortExpression="NumberOfSeats" />
                        <asp:BoundField DataField="Number of Bookings" HeaderText="Number of Bookings" ReadOnly="True"
                            SortExpression="Number of Bookings" />
                        <asp:TemplateField HeaderText="">
                            <ItemTemplate>
                                <asp:Button ID="sendButton" runat="server" CssClass="button" Text="Send Reminder &rarr;"
                                    OnClick="btnSend_Click" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle Font-Bold="True" CssClass="complete" />
                    <EditRowStyle BackColor="#999999" />
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                </asp:GridView>

                <asp:HiddenField ID="HiddenField1" runat="server" />

                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PM_RegistrationSysDBConnectionString %>"

            SelectCommand="SELECT Events.Title, Events.Description, Events.Location, Events.StartDateTime, Events.EndDateTime, Events.NumberOfSeats, COUNT(BookingDetails.BookingID) AS [Number of Bookings] FROM Events INNER JOIN BookingDetails ON Events.ID = BookingDetails.EventID WHERE (Events.IsActive = 1) GROUP BY Events.Title, Events.Description, Events.Location, Events.StartDateTime, Events.EndDateTime, Events.NumberOfSeats ORDER BY Events.StartDateTime DESC"></asp:SqlDataSource>

C# Code:

protected void btnSend_Click(object sender, EventArgs e)
    {
        GridViewRow gvrow = (GridViewRow)(((Button)sender)).NamingContainer;
        HiddenField1.Value = ListOfAvailableEvents_GrivView.DataKeys[gvrow.RowIndex].Value.ToString();

        string title = gvrow.Cells[0].Text;
        string description = gvrow.Cells[1].Text;
        string location = gvrow.Cells[2].Text;
        string startDateTime = gvrow.Cells[3].Text;
        string endDateTime = gvrow.Cells[4].Text;

        string connString = ".............................;";

        using (SqlConnection conn = new SqlConnection(connString))
        {
            var sbEmailAddresses = new System.Text.StringBuilder(2000);
            int eventID = Convert.ToInt32(HiddenField1.Value);

            //Open DB connection
            conn.Open();

            string cmdText = @"SELECT     dbo.Events.Title, dbo.Employees.NetID
                                FROM         dbo.BookingDetails INNER JOIN
                                        dbo.Events ON dbo.BookingDetails.EventID = @EventID INNER JOIN
                                        dbo.Employees ON dbo.BookingDetails.NetID = dbo.Employees.NetID";
            using (SqlCommand cmd = new SqlCommand(cmdText, conn)) 
            {
                cmd.Parameters.AddWithValue("@EventID", eventID);
                cmd.ExecuteNonQuery();

                SqlDataReader reader = cmd.ExecuteReader();
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        var sName = reader.GetString(0);
                        if (!string.IsNullOrEmpty(sName))
                        {
                            if (sbEmailAddresses.Length != 0)
                            {
                                sbEmailAddresses.Append(", ");
                            }
                            sbEmailAddresses.Append(sName).Append("@appServer.com");
                        }
                    }
                }
                reader.Close();

                var sEMailAddresses = sbEmailAddresses.ToString();
                string body = "..........................";


                int sendCount = 0;
                List<string> addressList = new List<string>(sEMailAddresses.Split(','));
                StringBuilder addressesToSend = new StringBuilder();

                for (int userIndex = 0; userIndex < addressList.Count; userIndex++)
                {
                    sendCount++;
                    if (addressesToSend.Length > 0)
                        addressesToSend.Append(",");

                    addressesToSend.Append(addressList[userIndex]);
                    if (sendCount == 10 || userIndex == addressList.Count - 1)
                    {
                        SendEmail(addressesToSend.ToString(), "", "Registration REMINDER Notification", body, true);
                        addressesToSend.Clear();
                        sendCount = 0;
                    }
                }

                cmd.ExecuteNonQuery();
            }
            //reset the value of hiddenfield
            HiddenField1.Value = "-1";
        }
    }

    protected void SendEmail(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml)
    {
        SmtpClient sc = new SmtpClient("MAIL ADDRESS");
        try
        {
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress("app@appServer.com", "Registration System");

            // In case the mail system doesn't like no to recipients. This could be removed
            //msg.To.Add("app@appServer.com");

            msg.Bcc.Add(toAddresses);
            msg.Subject = MailSubject;
            msg.Body = MessageBody;
            msg.IsBodyHtml = isBodyHtml;
            sc.Send(msg);
        }
        catch (Exception ex)
        {
            throw ex;
            // something bad happened
            //Response.Write("Something bad happened!");

        }

    }

But I could not be able to send any emails. Could you please tell me why?

UPDATE:

I wrote the code and when I run it, I did not get any error. I tried to debug it and when I did that I found the call to SendEmail(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml) method is not working and I don’t know why.

So could you please tell me how I can send emails to the registered users of the selected event?

  • 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-16T08:09:10+00:00Added an answer on June 16, 2026 at 8:09 am
    for (int userIndex = 0; userIndex < addressList.Count-1; userIndex++)
                    {
    

    check this for loop once

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

Sidebar

Related Questions

I am a new ASP.NET developer and I am developing a simple intranet registration
I am a new C# and ASP.NET developer. I am developing a simple intranet
I am a new ASP.NET developer and I am developing a traning management system
I am a new ASP.NET developer and I am trying to develop a simple
I am a New ASP.NET Developer and I am trying to develop a simple
I am a new ASP.NET developer and I am developing a web-based suggestions box
I am a new ASP.NET developer and now I am having an issue in
I am a new ASP.NET developer and trying to use ASP.NET Ajax BallouPopupExtender with
I am a new ASP.NET developer and trying to use a GridView control to
I am a new ASP.NET developer and trying to use a GridView control to

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.