Ejemplo n.º 1
0
        public async Task <(bool result, string errorMessage)> SendEmail(SendgridData data)
        {
            try
            {
                var sendgridClient = new SendGridClient(data.SendgridApiSecret);

                var addressee = new EmailAddress(data.AddresseeEmail, data.AddresseeName);

                var sender = new EmailAddress("*****@*****.**", "Eduardo Medina");

                var message = MailHelper.CreateSingleEmail(sender, addressee, data.Title, data.Content, data.Content);

                var result = await sendgridClient.SendEmailAsync(message);

                if (result.StatusCode != HttpStatusCode.OK)
                {
                    return(false, "Error when sending email...");
                }

                return(true, null);
            }
            catch (Exception ex)
            {
                return(false, ex.Message);
            }
        }
Ejemplo n.º 2
0
        public async Task Handle(EmailEventQueue @event)
        {
            var sendgridData = new SendgridData()
            {
                SendgridApiSecret = _configuration["Sendgrid:ApiSecret"],
                AddresseeName     = @event.Addressee,
                AddresseeEmail    = @event.Addressee,
                Title             = @event.Title,
                Content           = @event.Content
            };

            var result = await _sendgridSend.SendEmail(sendgridData);

            if (result.result)
            {
                await Task.CompletedTask;
                return;
            }
        }