Click here to Skip to main content
15,914,070 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
i used text boxes and a submit button on my .aspx page and i want to email the data of all these text boxes on Button click.
so please tell me the solution.....
Posted

here is sample code to sending email with attachment

http://hemantrautela.blogspot.in/2012/09/advance-email-sending-codecnet-with.html[^]
 
Share this answer
 
Solutions are many but you need to find appropriate as your requirement.

Try on Google[^] search.

Then you can try similar answers on CodeProject[^]

And you can try CodeProject[^] articles too on same.
 
Share this answer
 
 
Share this answer
 
 
Share this answer
 
hi sidhu once look at this, it having clear description..

http://www.aspdotnet-suresh.com/2010/11/introduction-this-article-i-will.html[^]
 
Share this answer
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Data;
using System.Web.Mail;
using System.Net;
using System.Net.Mail;
using System.IO;
using System.Drawing;
using System.Xml;

protected void btnSend_Click(object sender, EventArgs e)
{
try
{
System.Net.Mail.MailMessage obj = new System.Net.Mail.MailMessage();

SmtpClient serverobj = new SmtpClient();
serverobj.Credentials = new NetworkCredential("anilmeets4u@gmail.com", "password");
serverobj.Port = 587;
serverobj.Host = "smtp.gmail.com";
serverobj.EnableSsl = false;
obj = new System.Net.Mail.MailMessage();
obj.From = new MailAddress("anilmeets4u@gmail.com", "AgileLearning.com", System.Text.Encoding.UTF8);
obj.To.Add(ASPxtxtToUser.Text);
obj.CC.Add(txtCcUser.Text);
obj.Priority = System.Net.Mail.MailPriority.High;
obj.Subject = txtSubject.Text;
string date = DateTime.Now.ToString();
obj.Body = ASPxMemo1.Text;
HttpFileCollection hfc = Request.Files;
for (int z = 0; z < hfc.Count; z++)
{
HttpPostedFile hpf = hfc[z];
if (hpf.ContentLength > 0)
{
uploadfile.SaveAs(Server.MapPath("MailFiles") + "\\" + Path.GetFileName(hpf.FileName));
string FileName = Server.MapPath("MailFiles") + "\\" + Path.GetFileName(hpf.FileName);

obj.Attachments.Add(new Attachment(FileName));
obj.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;


serverobj.Send(obj);
Page.RegisterClientScriptBlock("pageClose", "<script>alert('Your Request Send Sucessfully');</script>");
}
}



}


catch (Exception ex)
{
ex.ToString();
}


}


Try this it will work
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900