To send email from your application or website do the following:
1. Add this config entry to your (App)(Web).config altering the host to the URL or IP address of your email server with the associated credentials.
<system.net>
<mailSettings>
<smtp from="noreply@medimedia.com">
<network host="localhost" password="" userName="" />
</smtp>
</mailSettings>
</system.net>
2. Use the following code to create and send a MailMessage
Version:0.9 StartHTML:0000000105 EndHTML:0000007499 StartFragment:0000000105 EndFragment:0000007499
private void SendEmail()
{
MailMessage message = new MailMessage();
message.From = new MailAddress(_fromEmail);
foreach (string email in _emailList)
{
message.To.Add(new MailAddress(email));
}
message.Subject = _subject;
message.IsBodyHtml = false;
message.Priority = MailPriority.High;
message.Body = _body;
try
{
SmtpClient client = new SmtpClient();
client.Send(message);
}
catch (Exception ex)
{
//TODO: Handle exception
}
}