Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > Intro Programming
|
Intro Programming What is a loop? Which language is best for beginners? What is "object oreinted?" All those types of questions and more are welcome here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Intro Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 18th, 2011, 03:36 AM
Registered User
 
Join Date: Aug 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to add file upload control in feedback form?

Hi,
This is santosh from India. My friednd told me about your online forum. It is very good effort of any programmer. I am learing webdesigning and working on project in which I would like to add file upload control. Pls look into the error.



public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnsend_Click(object sender, EventArgs e)
{
{
MailMessage mail = new MailMessage();

mail.To.Add(txtTo.Text);
mail.From = new MailAddress(txtFrom.Text);
mail.CC.Add = (txtCC.Text);



mail.Subject = txtSubject.Text;
mail.Body = txtMessage.Text;

mail.IsBodyHtml = true;

//Attach file using FileUpload Control and put the file in memory stream
if (FileUpload1.HasFile)
{
mail.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
}
if (FileUpload2.HasFile)
{
mail.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
}
if (FileUpload3.HasFile)
{
mail.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
}
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("[email protected]", "********");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);

}
}
}


The contact form is working fine but the only problem is that I am not getting senders email addres in From "[email protected]" always comes whcih my email address and the problem is that if I do not know who send me email then how can I reply him.. So I would like to grab the sender's email addres by creating a textbox inwhich visitor has to fill his email address and that email address delivered as body of email.
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create contact form with file upload control ? Ranveer@2468 ASP.NET 4 General Discussion 0 August 17th, 2011 07:30 AM
How to add file upload facilty in feedback form ? Ranveer@2468 BOOK: Beginning ASP.NET 4 : in C# and VB 1 August 17th, 2011 02:22 AM
Clear the filepath details of File Upload Control after saving a file DineshGirij008 C# 2005 0 March 7th, 2009 03:52 AM
File Upload Control surendraparashar ASP.NET 2.0 Professional 6 November 6th, 2007 07:39 AM
File upload control miltonsnider BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 December 12th, 2006 06:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.