SmtpClient.Host = "localhost"; SmtpClient.Port = 25; ~~~~~~~~~~~~~~~~~~~~ SmtpClient.Send(message);
These lines try to use members of the SmtpClient class. However, since these members are not defined as static , you need to refer to an instance of this class that you called client .
Try
client.Host = "localhost"; client.Port = 25; ~~~~~~~~~~~~~~~~~~~~ client.Send(message);
Also, read this article about the differences between class and instance members.
Finally, since SmtpClient implements IDisposable, I would modify your code to wrap it in with a block, as this will ensure proper cleanup after the SMTP session ends.
using (SmtpClient client = new SmtpClient()) {
source share