How to send Email in ASP.Net 2.0
have changed from ASP.Net1.1 and ASP.Net 2.0, for email sending. The namespace has changed from System.Web.Mail to System.Net.Mail. and to get the email working, there are two classes that need to be addressed:
- MailMessage()
- SmtpClient()
using System.Net.Mail;
SmtpClient MailClient=new SmtpClient("127.0.0.1");
MailMessage Msg = new MailMessage(SenderAddress,ReceiptAddress);
Msg.Subject = "YourSubject";
string Message="";
Message="";
"; Thank you for registerting in allabout-dotnet.blogspot.com
Message += ""; Your EMail:" + txtEMail.Text.ToString() + "
Message += ""; Your Password:" + TxtPassword.Text.ToString() + "
Message += "
Msg.Body = Message;
Msg.IsBodyHtml = true;
try
{
MailClient.Send(Msg);
}
catch (System.Exception ex)
{
Response.Write(ex.toString());
}
As said earlier, several things have changed, and, it's not quite as easy as it was with ASP.Net version 1.1, but still, emailing in ASP.Net is not complicated at all.
0 comments:
Post a Comment