public static void SendEmail(SenderEntity entity) { try { var message = new MimeMessage(); message.From.Add(new MailboxAddress("AcheBarato", "*****@*****.**")); message.To.Add(new MailboxAddress(entity.UserName, entity.UserEmail)); message.Subject = "Alerta de preço!!"; message.Body = new TextPart("plain") { Text = $@" Olá, {entity.UserName.Split(" ")[0]}! Vimos que você pediu para que o(a) notificasse sobre o produto {entity.ProductName} no preço de R$ {entity.ProductPrice}! Não perca tempo, clique no link e boa compra! {entity.ProductLinkRedirect}" }; using (var client = new SmtpClient()) { client.Connect("smtp.gmail.com", 587, SecureSocketOptions.StartTls); // Note: only needed if the SMTP server requires authentication client.Authenticate("*****@*****.**", "nblsgutkedovhkww"); client.Send(message); client.Disconnect(true); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } }
public static Sender ToDomain(this SenderEntity sender) { return(new Sender() { Id = sender.Id, Email = sender.Email, Password = sender.Password }); }
public static void SendSms(SenderEntity entity) { string accountSid = "AC1f23341bbbd8f2427e79bbc100da08b0"; string authToken = "65e59ac5908aac0ce495814dbf47ea1d"; TwilioClient.Init(accountSid, authToken); var to = entity.UserPhone; var from = "+18478921617"; var message = MessageResource.Create( to: to, from: from, body: $"O produto {entity.ProductName } que você escolheu chegou a faixa de preço desejada link: {entity.ProductLinkRedirect}"); Console.WriteLine(message.Sid); Console.ReadLine(); }