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"));
        }
Пример #2
0
        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);
            }
        }