public void SendMessage(MailMessage mailMessage) { var sb = new StringBuilder(); var lineBreak = mailMessage.IsBodyHtml ? "<br />" : "\r\n"; foreach (var mailAddress in mailMessage.To) { sb.Append(BuildLine(nameof(mailMessage.To), mailAddress, lineBreak)); } foreach (var mailAddress in mailMessage.CC) { sb.Append(BuildLine(nameof(mailMessage.CC), mailAddress, lineBreak)); } foreach (var mailAddress in mailMessage.Bcc) { sb.Append(BuildLine(nameof(mailMessage.Bcc), mailAddress, lineBreak)); } sb.Append(mailMessage.Body); mailMessage.Body = sb.ToString(); mailMessage.To.Clear(); mailMessage.CC.Clear(); mailMessage.Bcc.Clear(); mailMessage.To.Add(_debugAddress); mailMessage.BodyEncoding = Encoding.UTF8; _mailSender.SendMessage(mailMessage); }
protected async override Task <WorkflowResult> PerformStep(string input, Subscriber subscriber, long chatId) { if (CurrentStep == (int)Steps.Start) { await Notifier.RequestEmail(chatId.ToString()); CurrentStep = (int)Steps.EnterEmail; return(WorkflowResult.Continue); } if (CurrentStep == (int)Steps.EnterEmail) { if (string.IsNullOrWhiteSpace(input) || !input.EndsWith(Config.EmailDomain)) { await Notifier.IncorrectEmail(subscriber.TelegramId); CurrentStep = (int)Steps.EnterEmail; return(WorkflowResult.Continue); } subscriber.Email = input; subscriber.IsVerified = false; subscriber.Pin = _pinGenerator.GetRandomPin(); await Notifier.EmailUpdated(subscriber); _mailSender.SendMessage("UN Big Brother bot verification code", $"Please send the following PIN to the bot through the chat: {subscriber.Pin}", subscriber.Email); CurrentStep = (int)Steps.VerifyEmail; return(WorkflowResult.Continue); } if (CurrentStep == (int)Steps.VerifyEmail) { var isNumeric = int.TryParse(input, out int code); if (isNumeric) { if (await VerifyAccount(subscriber, code)) { return(WorkflowResult.Finished); } return(WorkflowResult.Continue); } await Notifier.CouldNotVerifyAccount(subscriber); return(WorkflowResult.Continue); } return(WorkflowResult.Finished); }
public IActionResult Contact(ContactViewModel model) { if (ModelState.IsValid) { //Send Mail _mailSender.SendMessage("*****@*****.**", model.Subject, $"From: {model.Name} - {model.Email}, Message: {model.Message}"); ViewBag.UserMessage = "Mail Sent"; ModelState.Clear(); } return(View()); }
public async Task MakeOrder( UserDto userDto, List <OrderedProductDto> orderedProducts, decimal price, decimal advance) { var user = await _userDao.GetByEmail(userDto.Email); if (user == null) { user = userDto; user.CreationSource = UserCreationSource.MadeOrder; user.SubscriptionOptions = SubscriptionOption.All; user.Id = await _userDao.AddUser(user); } ; var tasks = orderedProducts.Select(op => _modelParser.ParseFromSku(op.Sku)); var models = (await Task.WhenAll(tasks)).GroupBy(m => m.Sku).ToDictionary(m => m.Key, m => m.First()); foreach (var prod in orderedProducts) { prod.SerializedProduct = JsonConvert.SerializeObject(models[prod.Sku], Formatting.Indented); prod.ProductLink = $"https://ujin.org/ua/model/{models[prod.Sku].Identifier}?sku={prod.Sku}"; } var order = new OrderDto { UserId = user.Id, Price = price, Advance = advance, OrderedProducts = orderedProducts }; await _orderDao.AddOrder(order); await _mailSender.SendMessage(new SimpleMail { From = _mailSettings.SupportMail, To = _mailSettings.MailTo, Subject = "Ujin jewelry: new order", Body = GenerateMailMessage(order, user) }); }
public void Send(Email email, UserId toUser) { var userDetails = repo.UserDetails(toUser); sender.SendMessage(userDetails.Email, email); }
public void SendMailShot(string to, string body) { _sender.SendMessage(new EmailMessage { To = to, Body = body }); }