I have the following code but I am getting an exception that a smtp host is not defined. If I am running this and testing on my local machine from visual studio, what do I need to do to be able to send email from my machine. Do I have to turn on some Windows service?
private void SendMailToAdminToApprove(string email_, string name_)
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("[email protected]", "Person's Name");
msg.To.Add(new MailAddress("[email protected]", "Adam"));
msg.Subject = "Message Subject";
msg.Body = "Mail body content";
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
try
{
SmtpClient c = new SmtpClient();
c.Send(msg);
}
catch (Exception ex)
{
Console.Write("T");
}
}