using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
public static void Run(TimerInfo myTimer, ILogger log)
{
MailMessage mailMsg = new MailMessage();
mailMsg.To.Add(new MailAddress("someone@yahoo.com"));
mailMsg.From = new MailAddress("support@mydomain.com");
mailMsg.Subject = "Test email from Azure Function";
string html = @"<strong>HTML text for Azure Function</strong>";
mailMsg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html));
using (SmtpClient client = new SmtpClient())
{
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("support@mydomain.com", "mypw01");
client.Host = "smtp.gmail.com";
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(mailMsg);
}
log.LogWarning("Email Sent");
}
Comments