How to you add email to a Core 7 Web App?

Mark Phillips 0 Reputation points

In .net framework its easy to add SMTP email services to an app via the _AppStart file.

Now that I'm trailling Core 7 - how do I add email to the Demo app?

Most of the guidance on the net applies to a Core API which is irrelevant as I'm just doing a simple Core App via the Add new Proejct - ASP.NET Core Web app template.

A set of technologies in the .NET Framework for building web applications and XML web services.
3,757 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Mark Phillips 0 Reputation points

    Thanks, but there seems to be missing steps in this example solution.

    eg there's no Startup.cs file in the Demo install (and I don't know what it is anyway :) )

    And I don't use SendGrid - just a normal SMTP email server setup is enough for me now.

    0 comments No comments

  2. Chandra Mohan Hundigam Venkat 11 Reputation points

    Use .NET SmptClient class as shown below

    using Microsoft.AspNetCore.Identity.UI.Services;
    using System.Net;
    using System.Net.Mail;
    using System.Threading.Tasks;
    namespace YourProject.Services
        public class EmailSender : IEmailSender
            public Task SendEmailAsync(string email, string subject, string htmlMessage)
                SmtpClient client = new SmtpClient
                    Port = 587,
                    Host = "", //or another email sender provider
                    EnableSsl = true,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials = new NetworkCredential("your email sender", "password")
                return client.SendMailAsync("your email sender", email, subject, htmlMessage);

  3. Bruce ( 48,476 Reputation points

    In min api apps, program.cs is the startup file.

    0 comments No comments