Waqar Malik Waqar Malik - 1 year ago 91
ASP.NET (C#) Question

Why am I getting error in this term expression?

I have a error message when I hover over this line

"An object reference is required for the non static field, method or
property 'SmtpClient.send(mailMessage)'

SmtpClient smtpClient = new SmtpClient();
SmtpClient.Send(mailMessage); //Error over this line

Answer Source

You're referencing the class, not your variable.

SmtpClient smtpClient = new SmtpClient();

This will fix it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download