How to send the bulk emails with attachments? [Resolved]

Posted by Ses under ASP.NET on 9/17/2013 | Points: 10 | Views : 1046 | Status : [Member] | Replies : 4
how to send bulk emails with attachments dos and pics using asp.net

seshu


Responses

Posted by: aswinialuri-19361 on: 9/19/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
hi ,
try this it will help you
<body>

<form id="form1" runat="server">
<div>
<h1 align="center">Sending an Email</h1>
<table align="center">
<tr><td>To:</td><td><asp:TextBox ID="txt1_to" runat="server"></asp:TextBox></td></tr>

<tr><td>subject:</td><td><asp:TextBox ID="txt_sub" runat="server"></asp:TextBox></td></tr>

<tr><td>Body:</td><td><asp:TextBox ID="txt_body" runat="server"></asp:TextBox></td></tr>

<tr><td>Attachment:</td><td><asp:FileUpload ID="fle1" runat="server" /></td></tr>

<tr><td colspan="2" align="center"><asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" /></td></tr>
</table>
</div>
</form>
</body>
</html>

Code Behind:
in an button click event

 protected void Button1_Click(object sender, EventArgs e)

{
MailMessage msg = new MailMessage("aswinialuri@gmail.com", txt1_to.Text);

msg.IsBodyHtml = true;
msg.Subject=txt_sub.Text.ToString();
msg.Body=txt_body.Text.ToString();
if(fle1.HasFile)
{
msg.Attachments.Add(new Attachment(fle1.PostedFile.InputStream, fle1.FileName));
}
NetworkCredential nc = new NetworkCredential("aswinialuri@gmail.com", "yourpwd@");
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = nc;
smtp.Send(msg);
}



Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Ses, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 9/17/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
http://www.codeproject.com/Articles/10828/Sending-Email-with-attachment-in-ASP-NET-using-SMT

If this post helps you mark it as answer
Thanks

Ses, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 9/17/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear Seshu,

You can use following code for this purpose:

//button click event

protected void btnSendEmails_Click(object sender, EventArgs e)
{
try
{
DataSet dsClients = GetClientDataSet();
if (dsClients.Tables["CLIENTS"].Rows > 0)
{
foreach (DataRow dr in dsClients.Tables["CLIENTS"].Rows)
{
SendMail(dr["Email_Address"].ToString());
}
}
}
catch (Exception ex)
{
}
}
///
/// Creates and returns a DataSet using Ms Access OleDBConnection and an OleDBDataAdapter
///
///
/// A DataSet from Ms Access using an OleDBConnection and an OleDBDataAdapter
///
private System.Data.DataSet GetClientDataSet()
{


//retrieve the connection string from the ConnectionString Key in Web.Config
string connectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];


//create a new OleDB connection
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connectionString);


//pass the Select statement and connection information to the initializxation constructor for the OleDBDataAdapter
System.Data.OleDb.OleDbDataAdapter myDataAdapter = new System.Data.OleDb.OleDbDataAdapter("SELECT Email_Address FROM CLIENTS", conn);


//Create a new dataset with a table : CLIENTS
System.Data.DataSet myDataSet = new System.Data.DataSet("CLIENTS");


//Fill the dataset and table with the data retrieved by the select command
myDataAdapter.Fill(myDataSet, "CLIENTS");


//return the new dataset created
return myDataSet;
}
private void SendEmail(string EmailAddress)
{
//Send Email Functionality here
}


Happy Coding

If it helps you or directs U towards the solution, MARK IT AS ANSWER

Ses, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/19/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer these links
http://www.aspsnippets.com/Articles/How-to-send-email-with-Multiple-Attachments-in-ASPNet-Website.aspx
http://forums.asp.net/t/1276617.aspx

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Ses, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response