コード例 #1
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);
            }
        }
コード例 #2
0
        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);
            }
        }