Author: semaran | Posted on: 12/19/2008 10:10:55 AM | Views : 299

Hi, i m new to this forum and to asp.net

I m trying to send email from my asp.net page using smtpclient. I m getting an error saying "Error creating object reference:could not create instance of an object.".  When i debug, it throws the error at smtpclient.send method.

Here is my code:
 try
{

MailAddress toAddress = new MailAddress("maran@makefriendsonline.com");

MailAddress fromAddress = new MailAddress(txtEmail.Text.Trim());

MailMessage msg = new MailMessage();

msg.To.Add(toAddress);

msg.From = fromAddress;

msg.Subject = "New Customer Enquiry";

 msg.IsBodyHtml = true;

string msgBody = txtMessage.Text.ToString();

msg.Body = msgBody;

SmtpClient smtp = new SmtpClient("localhost");

smtp.Send(msg);

}

catch (Ex ...

Go to the complete details ...