Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 5 A. Write a script that allow an administrator to send a reply email t

ID: 3712212 • Letter: Q

Question

QUESTION 5 A. Write a script that allow an administrator to send a reply email to a desired customer. The administrator able to input the customer's details (such as name and email) and the reply message through a HTML form. An email will be sent to the customer once the administrator clicks the send button. B. Write a script that allow the system to send a random generated password based on user's email that read from database. You are required to use a user table in a database (create a new table if is needed) and retrieve the user's email based on the username that selected by administrator. Read all the username from the table and display them in a drop-down list.

Explanation / Answer

  

This is Two layer program the first layer is for Frontend the second layer is for back end .
i have used html for front end and c#.net for backend.

Step first for frontend (Create A Form ) -:

<div class="container-fluid">
<div class="form-group">
<div class="row">
<div class="col-sm-2 control-label">
<b>Customer Name :</b></label></div>
<div class="col-sm-6">
<input type="text" class="form-control" id="txtcustomername" name="txtcustomername"   placeholder="Customer Name"   />
</div>
</div>


<div class="row">
<div class="col-sm-2 control-label">
<b>Email ID :</b></label></div>
<div class="col-sm-6">
<input type="text" id="email" class="form-control" placeholder="Email-ID" />
</div>
</div>
</br>

<b>Message:</b><textarea rows="4" cols="50">

</textarea>

</br>

<div class="row" >
<div class="col-sm-12">

<asp:Button id="btnsubmit" runat="server" Text="Submit"
        class="btn btn-success btn-lg   buttonproperty"      />

</div>
</div>


// Html Code Ends Here>

Important Namespaces Used
---------------------------

using System.Data;
using System.Data.SqlClient;
using System.Net.Mail;
using System.Net;

---------------------------

static variable used
--------------------

static int totalemailsent;


---------------------

Page Load Coding
---------------------

countRegistration();
        totalemailsent = 0;


--------------------

User Defined Method
-------------------

private void countRegistration()
    {

        String mycon = "Data Source=HP-PC\SQLEXPRESS; Initial Catalog=EmailRegistration; Integrated Security=True";
        String myquery = "Select count(*) from customerRegistered";
        SqlConnection con = new SqlConnection(mycon);
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = myquery;
        cmd.Connection = con;
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = cmd;
        DataSet ds = new DataSet();
        da.Fill(ds);
        Label3.Text= ds.Tables[0].Rows[0][0].ToString();
        con.Close();
    }


private void sendemail(String emailid,String cname, String subject, String message)
    {
        SmtpClient smtp = new SmtpClient();

        smtp.Port = 587;
        smtp.Credentials = new System.Net.NetworkCredential("Your EmailId", "YOUR PASSWORD");
        smtp.EnableSsl = true;
        MailMessage msg = new MailMessage();
        msg.Subject = subject;
        msg.Body = "Dear " + cname + " " + message+" Thanks & Regards your name";
        string toaddress = emailid;
        msg.To.Add(toaddress);
        string fromaddress = "<youremailid>";
        msg.From = new MailAddress(fromaddress);
        try
        {
            smtp.Send(msg);
            totalemailsent = totalemailsent + 1;

        }
        catch
        {
            throw;
        }
    }


-------------------

Send Email Button Click Event Coding
----------------------------------

String mycon = "Data Source=HP-PC\SQLEXPRESS; Initial Catalog=EmailRegistration; Integrated Security=True";
        String myquery = "Select * from customerRegistered";
        SqlConnection con = new SqlConnection(mycon);
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = myquery;
        cmd.Connection = con;
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = cmd;
        DataSet ds = new DataSet();
        da.Fill(ds);
        int rowcounter = ds.Tables[0].Rows.Count;
        int i = 0;
        while(i<rowcounter)
        {

            sendemail(ds.Tables[0].Rows[i]["emailaddress"].ToString(), ds.Tables[0].Rows[0]["name"].ToString(), TextBox1.Text, TextBox2.Text);
            i++;
        }
        Label4.Text = "Total Emails " + totalemailsent + " Sent to Registered Customer Successfully";

?-------------------- Answer of 2nd question ----------------------------------------------------

Register Button Click Event Coding
----------------------------

String pass = "abcdefghijklmnopqrstuvwxyz123456789";
        Random r = new Random();
        char[] mypass = new char[5];
        for(int i=0;i<5;i++)
        {
            mypass[i] = pass[(int)(35 * r.NextDouble())];

        }
        Label3.Text = "Thanks For Register : Your Generated Temporary Password is <b>" + new string(mypass)+"</b>";

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote