using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Configuration;
usingSystem.Data.SqlClient;
usingSystem.Data;
usingSystem.Net.Mail;
publicpartialclassBulkmail : System.Web.UI.Page
{
SqlConnectioncn;
SqlCommand cm;
SqlDataReaderdr;
SqlDataAdapter ad;
protectedvoidPage_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ }
}
protectedvoidSend_Click(object sender, EventArgs e)
{
String k = ConfigurationManager.AppSettings["my1"];
cn = newSqlConnection(k);
cn.Open();
foreach(GridViewRow r1 in GridView1.Rows)
{
var ch1 = (CheckBox) r1.FindControl("ch");
if (ch1.Checked)
{
StringfromEmail = "youremail";
// from/to/sub/body
MailMessagemailmassage = newMailMessage(fromEmail,r1.Cells[1].Text,"Welcome","This is testing msg");
mailmassage.Attachments.Add(newAttachment(FileUpload1.FileContent,System.IO.Path.GetFileName(FileUpload1.FileName)));
SmtpClientsmtpClient= newSmtpClient("smtp.gmail.com", 587);
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = newSystem.Net.NetworkCredential(fromEmail, "PASSWORD");
try
{
smtpClient.Send(mailmassage);
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
}
String i = "select * from bulkmail";
cm = newSqlCommand(i, cn);
dr = cm.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
}
}
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Configuration;
usingSystem.Data.SqlClient;
usingSystem.Data;
usingSystem.Net.Mail;
publicpartialclassBulkmail : System.Web.UI.Page
{
SqlConnectioncn;
SqlCommand cm;
SqlDataReaderdr;
SqlDataAdapter ad;
protectedvoidPage_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ }
}
protectedvoidSend_Click(object sender, EventArgs e)
{
String k = ConfigurationManager.AppSettings["my1"];
cn = newSqlConnection(k);
cn.Open();
foreach(GridViewRow r1 in GridView1.Rows)
{
var ch1 = (CheckBox) r1.FindControl("ch");
if (ch1.Checked)
{
StringfromEmail = "youremail";
// from/to/sub/body
MailMessagemailmassage = newMailMessage(fromEmail,r1.Cells[1].Text,"Welcome","This is testing msg");
mailmassage.Attachments.Add(newAttachment(FileUpload1.FileContent,System.IO.Path.GetFileName(FileUpload1.FileName)));
SmtpClientsmtpClient= newSmtpClient("smtp.gmail.com", 587);
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = newSystem.Net.NetworkCredential(fromEmail, "PASSWORD");
try
{
smtpClient.Send(mailmassage);
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
}
String i = "select * from bulkmail";
cm = newSqlCommand(i, cn);
dr = cm.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
}
}
No comments:
Post a Comment