Hi i need mail coding with Example so pls send me soon as possible
Thanks&Regs
Magesh
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Mar 17, 2012, 10:47 AM
Please post the error which you are getting...
magesh manavalanPosted Mar 17, 2012, 5:13 AM
SenthilkumarPosted Mar 17, 2012, 4:43 AM
The MailMessage comes under the namespace of System.Net.Mail.
Here is the sample code to send email.
MailMessage message = new MailMessage();
message.From = new MailAddress("[email protected]");
message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));
message.CC.Add(new MailAddress("[email protected]"));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
System.Net.Mail reads SMTP configuration data out of the standard .NET configuration system (so for ASP.NET applications you'd configure this in your application's web.config file). Here is an example of how to configure it:
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />
smtp>
mailSettings>
system.net>
Please go through this url. The MSDN has given the methods and properties of the MailMessage class with an code.
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx