<tr> <td><asp:Label id="lbloracle11gDBA" runat="server" Text="Oracle 11g DBA"></asp:Label></td> <td><asp:TextBox ID="txtoraclebatchid" runat="server" ontextchanged="txtoraclebatchid_TextChanged" AutoPostBack="true"></asp:TextBox></td> <td><asp:TextBox ID="txtoraclestdt" runat="server" ></asp:TextBox></td> <td><asp:TextBox ID="txtoracleendt" runat="server" ></asp:TextBox></td> <td><asp:TextBox ID="txtoracletimings" runat="server" ></asp:TextBox></td> <td><asp:FileUpload ID="upload" runat="server" /></td> <td><asp:Button ID="btnoraclesend" runat="server" Text="Send" onclick="btnoraclesend_Click" /></td> </tr>
using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Net.Mail; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnoraclesend_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source=xxxxx; User Id=xxxxx; Password=xxxxxx; Initial Catalog=xxxxxxx; Integrated Security=SSPI;"; conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "select EMail_1 from Student_Info where Branch_Code='ap' and Student_ID in(select Student_ID from Admissions where Branch_Code='ap' and Batch_ID='" + txtoraclebatchid.Text + "')"; cmd.CommandType = CommandType.Text; SqlDataAdapter da = new SqlDataAdapter(cmd); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows[0][0] != null) { int count = ds.Tables[0].Rows.Count; for (int i = 0; i < count; i++) { MailMessage mm = new MailMessage(); mm.To.Add(ds.Tables[0].Rows[i][0].ToString()); mm.From = new MailAddress("xxxxxxxxxx"); mm.Subject = "Asp.net Test Email"; if (upload.HasFile) { mm.Attachments.Add(new Attachment(upload.PostedFile.InputStream, upload.FileName)); } mm.Body = "Hello world"; SmtpClient s = new SmtpClient("smtp.xxxxxxxxx.com"); s.Send(mm); Response.Write("Email Sent"); } } conn.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)