 <p>I'd like to recommend these:</p> <ol> <li><p>Add the namespace to your class file. using System.Net.Mail;</p></li> <li><p>Provide arguments when you call the function (SendMailMessage).</p></li> <li><p>Make class SendMail as a static class, SendMailMessage as static function.</p></li> </ol>