SmtpClient
smtp = new SmtpClient(); MailMessage mail = new MailMessage();mail.From =
new MailAddress(txtFrom.Text);smtp.Credentials =
new NetworkCredential("User Id", "Password");mail.To.Add(txtTo.Text);
mail.Subject =
"Mail Sending";mail.Body = rtxtBody.Text;
smtp.Host =
"smtp.gmail.com";smtp.Port = 25;
smtp.EnableSsl =
true;
smtp.Send(mail);
MessageBox.Show("Mail sent succesfully");
With this I am getting the mail sent to the user id given in credentials. But I need the mail to be send to the address entered by the user in the from text box. I am getting mail sent to 'To' address correctly. But this is the problem with from. Can you please help me?
And also when we reply to the mail sent, the to address should be the address address by the first user in default. I think I can get this with mail send to the address entered by the user.
Niradhip ChakrabortyPosted Sep 1, 2008, 2:03 PM
You need to go to your reference list in your solution file and right
click on "References" and choose "Add Reference". Under the .NET tab,
choose System.Web.dll and add it to your project.
USE System.Web.Mail NAMESPACE to send mail.
You also can refer thr following article:
1.http://www.dotnetspider.com/resources/2778-How-send-email-orugh-C-windows-application.aspx
Ram Reddy MekhaPosted Sep 1, 2008, 10:20 AM
jerry williamsPosted Aug 31, 2008, 2:56 AM
Hi there, it would be helpful if you could provide us with some more details, is the application in what form ,by that i mean is it asp.net and if it is , which version
regards