TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
eda adura
NA
20
489
Delete a certain rows from database after read read the data
May 22 2017 3:50 AM
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td style="width: 80px">To:</td>
<td>
<asp:TextBox ID="txtTo" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Subject:</td>
<td>
<asp:TextBox ID="txtSubject" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align = "top"> Body: </td>
<td>
<asp:TextBox ID="txtBody" runat="server" TextMode = "MultiLine" Height = "150" Width = "200"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Gmail Email:</td>
<td><asp:TextBox ID="txtEmail" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Gmail Password:</td>
<td><asp:TextBox ID="txtPassword" runat="server" TextMode = "Password"></asp:TextBox></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td></td>
<td><asp:Button Text="Send" OnClick="SendEmail" runat="server" /> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
======================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Data;
using System.Data.SqlClient;
public partial class email : System.Web.UI.Page
{
SqlCommand cmd = new SqlCommand();
SqlConnection con = new SqlConnection();
protected void Page_Load(object sender, EventArgs e)
{
con.ConnectionString = @"Data Source=PC\GAMETAIKO;Initial Catalog=login;Integrated Security=True";
}
protected void SendEmail(object sender, EventArgs e)
{
con.Open();
String query = "INSERT INTO cubaan2 (fromSender, toSender, subjectSender, status) VALUES( '" + txtEmail.Text + "', '" + txtTo.Text + "', '" + txtSubject.Text + "', '" + "' ) ";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
SDA.SelectCommand.ExecuteNonQuery();
con.Close();
using (MailMessage mm = new MailMessage(txtEmail.Text, txtTo.Text))
{
mm.Subject = txtSubject.Text;
mm.Body = txtBody.Text;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential(txtEmail.Text, txtPassword.Text);
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true);
}
}
}
=====================================================================
this is the code i use to do a simple 'send an email using asp.net', i have a few problem.
after the email send, it will store in database the content of the email. Can someone help me, i want the email content in database will be deleted after admin had read it.
Thank you so much.
Reply
Answers (
1
)
Tamil Font in Asp.net Textbox
Close current browser tab