You must Sign In to post a response.
  • Category: ASP.NET

    How to store copy of Email in database using SQL Server,C#,ASP.net.

    Hi

    I have created web application with sending emails from asp.net,c#.

    I want to store the copy of the email(sender,receiver,content) in database SQL table for future reference.

    Rerieve the email from the database SQL table with the same content and line spaces,commas,semicolon ,that was sent from asp.net,c#

    Rerieved content can be displayed in PDF or some other file type.

    Please any solution is appreciated.

    Thanks and Regards

    Ramachandran.
  • #768299
    You can use this code snippet to Rerieve the email address and password from the database using C#
    create table Usertable
    (

    From Varchar(500)
    To Varchar(Max)
    Subject Nvarchar(Max)
    Body Nvarchar(Max)
    userPassword varchar(20),
    Email varchar(100)
    )

    Code Snippet for accept Email Address

    protected void Button2_Click(object sender, EventArgs e)
    {
    SqlConnection con = new SqlConnection("Data Source=.;uid=sa;pwd=wintellect;database=rohatash");
    SqlCommand com = new SqlCommand("RetrieveEmailPass", con);
    com.CommandType = CommandType.StoredProcedure;
    SqlParameter p1 = new SqlParameter("@userName", TextBox1.Text);
    com.Parameters.Add(p1);
    con.Open();
    SqlDataReader dr = com.ExecuteReader();
    if (dr.Read())
    {
    Label1.Text = "Your Email is: " + dr[1].ToString();
    }
    else
    {
    Label1.Text = "Email Address does not exist";
    }
    con.Close();
    }
    }

    Code behind for accept Password
    public partial class Default2 : System.Web.UI.Page
    {

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    SqlConnection con = new SqlConnection("Data Source=.;uid=sa;pwd=wintellect;database=rohatash");
    SqlCommand com = new SqlCommand("RetrieveEmailPass", con);
    com.CommandType = CommandType.StoredProcedure;
    SqlParameter p1 = new SqlParameter("@userName", TextBox1.Text);
    com.Parameters.Add(p1);
    con.Open();
    SqlDataReader dr = com.ExecuteReader();
    if (dr.Read())
    {
    Label1.Text = "Enter your Password : " + dr[0].ToString();
    }
    else
    {
    Label1.Text = "User Name does not exist";
    }
    con.Close();
    }


Sign In to post your comments