public async Task SendRegistrationSucceededMail(string toMail, string name, string username, string password) { //Set receipient List <SendSmtpEmailTo> To = new List <SendSmtpEmailTo>(); To.Add(new SendSmtpEmailTo(toMail, name)); //Define dummy content string HtmlContent = null; string TextContent = null; string Subject = null; //Set mail specific settings SendSmtpEmailReplyTo ReplyTo = senderReplyToMail; object parameters = new RegistrationMailModel { name = name, username = username, password = password, editAccountUri = System.Environment.GetEnvironmentVariable("EditAccountBaseUri") + $"?userid={username}&eMail={toMail}", }; try { var sendSmtpEmail = new SendSmtpEmail(senderMail, To, null, null, HtmlContent, TextContent, Subject, ReplyTo, null, null, welcomeMailTemplateId, parameters); CreateSmtpEmail result = await apiInstance.SendTransacEmailAsync(sendSmtpEmail); } catch (Exception e) { throw new Exception("Something went wrong while sending Mail", e); } }
public void Execute(string apiKey, string subject, string message, string email) { Configuration.Default.AddApiKey("api-key", apiKey); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Configuration.Default.AddApiKeyPrefix("api-key", "Bearer"); // Configure API key authorization: partner-key Configuration.Default.AddApiKey("partner-key", apiKey); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Configuration.Default.AddApiKeyPrefix("partner-key", "Bearer"); var apiInstance = new SMTPApi(); var sendSmtpEmail = new SendSmtpEmail(sender: new SendSmtpEmailSender("No-Reply", "*****@*****.**"), to: new List <SendSmtpEmailTo>() { new SendSmtpEmailTo(email, "Verify") }, htmlContent: message, subject: subject); try { // Send a transactional email CreateSmtpEmail result = apiInstance.SendTransacEmail(sendSmtpEmail); Debug.WriteLine(result); } catch (Exception e) { Debug.Print("Exception when calling SMTPApi.SendTransacEmail: " + e.Message); } //return true; }
public async Task SendEMail(string subject, string toMail, string content) { //Set receipient List <SendSmtpEmailTo> To = new List <SendSmtpEmailTo>(); To.Add(new SendSmtpEmailTo(toMail)); //Create Dummy Bcc and Cc var Bcc = new List <SendSmtpEmailBcc>(); var Cc = new List <SendSmtpEmailCc>(); string HtmlContent = content; string TextContent = null; string Subject = subject; SendSmtpEmailReplyTo ReplyTo = senderReplyToMail; try { var sendSmtpEmail = new SendSmtpEmail(senderMail, To, Bcc, Cc, HtmlContent, TextContent, Subject, ReplyTo); CreateSmtpEmail result = await apiInstance.SendTransacEmailAsync(sendSmtpEmail); } catch (Exception e) { throw new Exception("Something went wrong while sending Mail", e); } }
public override async Task <string> SendTemplate(EmailConstants.EmailTypes emailType, Dictionary <string, string> emailAttributes) { var to = new List <SendSmtpEmailTo>(); to.Add(new SendSmtpEmailTo(emailAttributes["ToEmail"], emailAttributes["ToUserName"])); var sendSmtpEmail = new SendSmtpEmail(to: to); sendSmtpEmail.TemplateId = EmailTypeToSendInBlueId(emailType); sendSmtpEmail.Params = emailAttributes; return(await SendViaSendInBlue(sendSmtpEmail)); }
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 async Task SendEmailAsync(string senderName, string senderEmail, string topic, string contentHTML, string recieverMail, string recieverName = "user") { var subject = topic; var htmlContent = contentHTML; var sender = new SendSmtpEmailSender(senderName, senderEmail); var to = new List <SendSmtpEmailTo> { new SendSmtpEmailTo(recieverMail, recieverName) }; var email = new SendSmtpEmail(sender, to, null, null, htmlContent, null, subject); try { CreateSmtpEmail result = await apiInstance.SendTransacEmailAsync(email); } catch (System.Exception ex) { System.Console.WriteLine("ERROR SMTP" + ex.Message); } }
private async Task <string> SendViaSendInBlue(SendSmtpEmail msg) { var configuration = new Configuration(); configuration.AddApiKey("api-key", emailSettings.SendInBlueSettings.ApiKey); var apiInstance = new SMTPApi(configuration); try { // Send a transactional email CreateSmtpEmail result = await apiInstance.SendTransacEmailAsync(msg); logger.LogDebug("SendInBlue sent email {Result}", result.MessageId); return(result.MessageId); } catch (Exception e) { throw new SendInBlueException("Exception when calling SMTPApi.SendTransacEmailAsync: ", e); } }
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); }