Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29762

Can I Send Emails to Multiple Receivers using IEmailSender Interface in ASP.Net Core 3.0

$
0
0

I'm beginner to ASP.Net core. Actually I'm using ASP.Net Core 3.0. I want to Send emails to Multiple Receivers. Can I use IEmailSender Interface? Or any suggetion?

My IEmailSender implementation is like,

public class EmailSender : IEmailSender
{
    private string host;
    private int port;
    private bool enableSSL;
    private string userName;
    private string password;

    public EmailSender(string host, int port, bool enableSSL, string userName, string password)
    {
        this.host = host;
        this.port = port;
        this.enableSSL = enableSSL;
        this.userName = userName;
        this.password = password;
    }

    public Task SendEmailAsync(string email, string subject, string htmlMessage)
    {
        var client = new SmtpClient(host, port)
        {
            Credentials = new NetworkCredential(userName, password),
            EnableSsl = enableSSL
        };
        return client.SendMailAsync(
            new MailMessage(userName, email, subject, htmlMessage) { IsBodyHtml = true }
        );
    }
}

Can anyone help me?


Viewing all articles
Browse latest Browse all 29762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>