How do you send an email in a Win10 IoT app (UWP) in the background for a headed application without showing an email app?
I see there is an EmailMessage and EmailManager class available but this only has:
EmailManager.ShowComposeNewEmailAsync()
Launches the email application with a new message displayed.
You can't send E-Mail through EmailManager
API without user interaction.
You need to use SmtpClient
to do so.
Like this:
public static void SendMail(MailMessage Message)
{
SmtpClient client = new SmtpClient();
client.Host = "smtp.googlemail.com";
client.Port = 587;
client.UseDefaultCredentials = false;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("[email protected]", "password");
client.Send(Message);
}
Or better check the microsoft example: Send Email with Attachment in C# from Windows Store Apps - XAML - UWP