p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Intro Programming (http://p2p.wrox.com/forumdisplay.php?f=194)
-   -   Problem in file upload control in asp.ent ? (http://p2p.wrox.com/showthread.php?t=84769)

asp.net123 August 18th, 2011 03:38 AM

Problem in file upload control in asp.ent ?
 
Hi,
This is santosh from India. My friend told me about your online forum. It is very good effort of any programmer. I am learing webdesigning and working on project on the platform asp.net 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
("panel.detail@gmail.com", "********");
//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 section of emial service provider "panel.detail@gmail.com" 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.

Imar August 19th, 2011 10:09 AM

Isn't that simply a matter of appending the address to the body?

mail.Body = txtMessage.Text + "\r\nFrom: " + txtFrom.Text;


Cheers,

Imar


All times are GMT -4. The time now is 05:16 AM.

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