public EmailService() { //Get E-Mail Instance var configuration = new Configuration(); configuration.ApiKey.Add("api-key", System.Environment.GetEnvironmentVariable("SendInBlueApiKey")); apiInstance = new TransactionalEmailsApi(configuration); welcomeMailTemplateId = long.Parse(System.Environment.GetEnvironmentVariable("RegistrationSucceededMailTemplateId")); //Define Sender Information senderMail = new SendSmtpEmailSender(System.Environment.GetEnvironmentVariable("eMailNameFrom"), System.Environment.GetEnvironmentVariable("eMailAddressFrom")); senderReplyToMail = new SendSmtpEmailReplyTo(System.Environment.GetEnvironmentVariable("eMailAddressFrom"), System.Environment.GetEnvironmentVariable("eMailNameFrom")); }
public async Task SendEmailAsync(string userEmail, string emailSubject, string message) { Configuration.Default.AddApiKey("api-key", _settings.Value.Key); var client = new TransactionalEmailsApi(); var msg = new SendSmtpEmail( new SendSmtpEmailSender(_settings.Value.User, "*****@*****.**"), new List <SendSmtpEmailTo> { new SendSmtpEmailTo(userEmail) }, htmlContent: message, textContent: message, subject: emailSubject ); await client.SendTransacEmailAsync(msg); }
public async Task SendEmailAsync(string userEmail, string emailSubject, string message) { Configuration.Default.AddApiKey("api-key", _config["Sendinblue:Key"]); var client = new TransactionalEmailsApi(); var msg = new SendSmtpEmail( new SendSmtpEmailSender(_config["Sendinblue:User"], _config["Sendinblue:User"]), new List <SendSmtpEmailTo> { new SendSmtpEmailTo(userEmail) }, htmlContent: message, textContent: message, subject: emailSubject ); await client.SendTransacEmailAsync(msg); }
public Task ExecuteAPI(string subject, string message, string email) { var configuration = _config.GetSection("Mailer").Get <MailerSettings>(); var sendSmtpEmail = new SendSmtpEmail(); sendSmtpEmail.Subject = subject; sendSmtpEmail.TextContent = message; sendSmtpEmail.Sender = new SendSmtpEmailSender(configuration.NameFrom, configuration.MailFrom); sendSmtpEmail.To = new List <SendSmtpEmailTo>(); sendSmtpEmail.To.Add(new SendSmtpEmailTo(email)); Func <SendSmtpEmail, CreateSmtpEmail> send = (mail) => { Configuration.Default.AddApiKey("api-key", configuration.ServiceApiKey); var apiInstance = new TransactionalEmailsApi(); return(apiInstance.SendTransacEmail(mail)); }; var TEnvoi = Task.Factory.StartNew(() => send(sendSmtpEmail)); return(TEnvoi); }