Here is a straightforward demonstration of how to send an email using .NET'S SMTPClient
using (System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage())
{
mailMessage.To.Add(new MailAddress(toAddress ));
mailMessage.From = new MailAddress(fromAddress, nameToAppearFrom);
mailMessage.Subject = subject;
mailMessage.Body = messageText;
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
}
To implement this functionality, you will also need to include Using System.Net.Mail ;
in your code file
and ensure the following configuration in your web config:
<system.net>
<mailSettings>
<smtp from="from address">
<network host="yourt mail server" defaultCredentials="false" port="port#" userName="username" password="password"/>
</smtp>
</mailSettings>
</system.net>
Another option, based on the database engine being used, is to send emails directly from the database. For example, setting up a scheduled task that retrieves birthdays and triggers a mail function or stored procedure.