public EmailService(IConfiguration configuration, NotificationMetadata notificationMetadata) { Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MzExMjM0QDMxMzgyZTMyMmUzMGJNZUF1RytQcUFUbFJuWEhoMWlLWi96eTh5U25IVEpuRVJWMWNtbGozU0E9"); this.configuration = configuration; _notificationMetadata = notificationMetadata; }
public async Task <bool> SendEmail(string asunto, string contenido, NotificationMetadata notificationMetadata) { try{ MailMessage mm = new MailMessage(notificationMetadata.Sender, notificationMetadata.Reciever, asunto, contenido); System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587) { EnableSsl = true, Credentials = new NetworkCredential(notificationMetadata.Sender, notificationMetadata.Password) }; await client.SendMailAsync(mm); //EmailMessage message = new EmailMessage(); //message.Sender = new MailboxAddress(notificationMetadata.Sender); //message.Reciever = new MailboxAddress(notificationMetadata.Reciever); //message.Subject = asunto; //message.Content = contenido; //var mimeMessage = CreateMimeMessageFromEmailMessage(message); //using (SmtpClient smtpClient = new SmtpClient()) //{ // await smtpClient.ConnectAsync(notificationMetadata.SmtpServer, notificationMetadata.Port, true); // await smtpClient.AuthenticateAsync(notificationMetadata.UserName, notificationMetadata.Password); // await smtpClient.SendAsync(mimeMessage); // await smtpClient.DisconnectAsync(true); //} return(true); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> SendEmail([FromQuery] string address, [FromQuery] string userName, [FromHeader] string password) { var _notificationMetadata = new NotificationMetadata(); var message = new MimeMessage(); message.From.Add(new MailboxAddress("Self", address)); message.To.Add(new MailboxAddress("Self", address)); message.Subject = "Welcome"; message.Body = new TextPart() { Text = "hello world" }; using (SmtpClient smtpClient = new SmtpClient()) { smtpClient.Connect("smtp.gmail.com", 465, true); smtpClient.Authenticate(userName, password); try { await smtpClient.SendAsync(message); smtpClient.Disconnect(true); return(Ok()); } catch (Exception e) { return(BadRequest(JsonConvert.SerializeObject(e, Formatting.Indented))); } } }
public async Task <bool> EnviarCorreo(ReqCorreo req) { Funciones fn = new Funciones(); NotificationMetadata noti = configuration.GetSection("NotificationMetadata").Get <NotificationMetadata>(); noti.Reciever = req.correo; return(await fn.SendEmail("Prueba correo", "Se envió información de FIREBASE desde API CORE \n" + "\n" + req.informacion, noti)); }
public void Setup() { var metadata = new NotificationMetadata(); metadata.Sender = "*****@*****.**"; metadata.SmtpServer = "smtp.gmail.com"; metadata.Port = 465; metadata.UserName = "******"; metadata.Password = "******"; _mailServer = new MailServer(metadata); }
public AuthController(IAuthRepository repo, IConfiguration config, IUserRepository userRepository, IBuildingRepository buildingRepository, IMailService mailService, NotificationMetadata notificationMetadata) { this._repo = repo; this._config = config; this._userRepository = userRepository; this._buildingRepository = buildingRepository; this._mailService = mailService; this._notificationMetadata = notificationMetadata; }
public async Task ProcessAsync(NotificationMetadata notificationMetadata, string rawEvent) { var twinChangedNotification = JsonConvert.DeserializeObject <TwinChangedNotification>(rawEvent); // Don't do anything if it's just reported twin updates if (twinChangedNotification.Properties.Desired == null && twinChangedNotification.Tags == null) { _logger.LogInformation("Device twin change ignored as it only contained reported properties"); return; } var twinInformation = TwinInformation.Parse(twinChangedNotification); await _deviceRegistryClient.NotifyTwinChangedAsync(notificationMetadata.DeviceId, twinInformation); _logger.LogInformation("Device twin change processed"); }
public async Task ProcessAsync(NotificationMessageSchemas messageSchema, NotificationMetadata notificationMetadata, string rawMessage) { IEventProcessor processor; switch (messageSchema) { case NotificationMessageSchemas.TwinChangeNotification: processor = _serviceProvider.GetRequiredService <TwinChangedNotificationProcessor>(); break; default: _logger.LogWarning("Message schema {MessageSchema} is not supported and being ignored", notificationMetadata.RawMessageSchema); return; } await processor.ProcessAsync(notificationMetadata, rawMessage); }
public void SendMail(NotificationMetadata _notificationMetadata, string receiver, string receiverName, string subject, MimeKit.Text.TextFormat textFormat, string content, string ccName, string cc, List <DigitalizedFile> digitalizedFiles) { EmailMessage message = new EmailMessage(); message.Sender = new MailboxAddress("Happy Gigas", _notificationMetadata.Sender); message.Reciever = new MailboxAddress(receiverName, receiver); message.Cc = new MailboxAddress(ccName, cc); message.Subject = subject; message.Content = content; var mimeMessage = CreateMimeMessageFromEmailMessage(message, textFormat, digitalizedFiles); using (SmtpClient smtpClient = new SmtpClient()) { smtpClient.Connect(_notificationMetadata.SmtpServer, _notificationMetadata.Port, true); smtpClient.Authenticate(_notificationMetadata.UserName, _notificationMetadata.Password); smtpClient.Send(mimeMessage); smtpClient.Disconnect(true); } }
public void Setup() { var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); DbContextOptions <NotificationContext> dbContextOptions = new DbContextOptionsBuilder <NotificationContext>() .UseMySql(config["ConnectionStrings:DbNotifications"]) .Options; _dbContext = new NotificationContext(dbContextOptions); _notificationsRepository = new NotificationsRepository(_dbContext); _notificationMetadata = new NotificationMetadata(); _smtpClient = new SmtpClient(); _notificationService = new NotificationService(_notificationsRepository); _notificationMetadata.SmtpServer = config["NotificationMetadata:SmtpServer"]; _notificationMetadata.Port = Int16.Parse(config["NotificationMetadata:Port"]); _notificationMetadata.UserName = config["NotificationMetadata:Username"]; _notificationMetadata.Password = config["NotificationMetadata:Password"]; _emailService = new EmailService(_notificationService, _notificationMetadata, _smtpClient); }
public EmailClientService(NotificationMetadata notificationMetadata) { _notificationMetadata = notificationMetadata; }
public MailService(NotificationMetadata notificationMetadata) { this._notificationMetadata = notificationMetadata; }
protected override async Task ProcessIndividualEventAsync(EventData eventData, string rawEventPayload) { var notificationMetadata = NotificationMetadata.Parse(eventData); await _eventProcessor.ProcessAsync(notificationMetadata.MessageSchema, notificationMetadata, rawEventPayload); }
public EmailGenerator(NotificationMetadata notificationMetaData) { _notificationMetadata = notificationMetaData; }
public VehicleInspectionController(IUnitOfWork unitOfWork, NotificationMetadata notificationMetadata) { _unitOfWork = unitOfWork; _notificationMetadata = notificationMetadata; }
public TopisimoController(TopisimoDbContext context, NotificationMetadata notificationMetadata) { _context = context; _notificationMetadata = notificationMetadata; }
public ValuesController(IUnitOfWork unitOfWork, NotificationMetadata notificationMetadata) { _unitOfWork = unitOfWork; _notificationMetadata = notificationMetadata; }
public EmailService(IConfiguration configuration) { this.notificationMetadata = configuration.GetSection("NotificationMetadata").Get <NotificationMetadata>(); }
public EmailService(INotIficationService notificationService, NotificationMetadata notificationMetadata, SmtpClient smtpClient) { _notificationMetadata = notificationMetadata; _smtpClient = smtpClient; _notIficationService = notificationService; }
public ShareService(NotificationMetadata notificationMetadata) { this._notificationMetadata = notificationMetadata; }