// GET: Email public ActionResult Index(string Email) { EmailVM model = new EmailVM(); model.Email = Email; return(PartialView(model)); }
public IActionResult SendEmail(EmailVM vm) { var imeUposlenika = HttpContext.GetLogiraniKorisnik(); var Korisnik = db.Korisnik.Where(b => b.KorisnickiNalogID == imeUposlenika.Id).FirstOrDefault(); if (ModelState.IsValid) { try { var message = new MimeMessage(); message.To.Add(new MailboxAddress(vm.Ime, vm.Email)); message.From.Add(new MailboxAddress(Korisnik.Ime + " " + Korisnik.Prezime, Korisnik.Email)); message.Subject = vm.Naslov; message.Body = new TextPart(TextFormat.Html) { Text = vm.Poruka + " Poruka je poslana od: " + vm.Ime + " E-mail: " + vm.Email }; using (var emailClient = new SmtpClient()) { emailClient.Connect("smtp.gmail.com", 587, false); emailClient.Authenticate("*****@*****.**", "password"); emailClient.Send(message); emailClient.Disconnect(true); } } catch (Exception ex) { ModelState.Clear(); ViewBag.Message = $" Nije u funkciji {ex.Message}"; } } TempData["Poruka-email"] = "Uspjesno ste poslali mail korisniku " + vm.Ime; return(Redirect("/Uposlenici/Clan?TeretanaID=" + vm.TeretanaID)); }
public async Task <RoleVM> getRole([FromBody] EmailVM email) { UserRoleRepo repo = new UserRoleRepo(service); RoleVM role = await repo.GetUserRole(email.Email); return(role); }
public async Task <IActionResult> Add([FromBody] EmailVM emailVM) { TOtherEntity relatedUser = await uw.Repository <TOtherEntity>() .GetAsync(u => u.UserName == emailVM.Email); if (relatedUser != null) { TEntity user = await getCurrentUser(); bool hasRelation = user.RelatedUsers.FirstOrDefault(p => p.UserName == emailVM.Email) != null; if (!hasRelation) { user.RelatedUsers.Add(relatedUser); await uw.Save(); await notifyHub.NotifyIfConnected(relatedUser.Id, user, NotifyState.OnRelationCreated); return(StatusCode((int)HttpStatusCode.Created)); } return(BadRequest(new ValidationError( ErrorType.UnexpectedError, "Such a user is already added!" ))); } return(NotFound(new ValidationError( ErrorType.UnexpectedError, "There is no such a user to add!" ))); }
public void PostEmail([FromBody] EmailVM emailVm) { Email email = new Email() { AuthorId = emailVm.AuthorId, Subject = emailVm.Subject, Body = emailVm.Body, DateCreated = DateTime.Now, ParentId = emailVm.ParentId }; foreach(var receiver in emailVm.Receivers) { email.UserEmail.Add(new UserEmail() { CategoryId = 1, UserId = receiver }); } email.UserEmail.Add(new UserEmail() { CategoryId = 4, UserId = emailVm.AuthorId }); _context.Email.Add(email); _context.SaveChanges(); }
public HttpResponseMessage SendEmail(EmailVM email) { try { var configService = _configService.GetAll().FirstOrDefault(); var companyName = configService.CompanyName; var sendingEmail = configService.Email; var emailPassword = configService.EmailPassword; var emailPort = configService.EmailPort; var emailSignature = configService.EmailSignature; var emailFrom = companyName + "<" + sendingEmail + ">"; var emailBody = ""; if (email.Body != null) { emailBody = email.Body + "<br /><br />" + emailSignature + "<br /><img src=\"cid:Pic1\">"; } else { emailBody = emailSignature + "<img src=\"cid:Pic1\">"; } XMail.Send(sendingEmail, emailPassword, emailPort, emailFrom, email.ToEmail, "", "", email.Subject, emailBody, ""); var responseMessage = new { message = "Gửi email thành công" }; return(Request.CreateResponse(HttpStatusCode.OK, responseMessage)); } catch (Exception) { var responseMessage = new { message = "Gửi email thất bại" }; return(Request.CreateResponse(HttpStatusCode.InternalServerError, responseMessage)); throw; } }
public static void SendMailAsync(EmailSettings Obj, EmailVM objemailvm, string path) { var fromAddress = new MailAddress(Obj.InfoEmail, "Techthrong"); var toAddress = new MailAddress(objemailvm.ToAddress, "Hacker Name"); string fromPassword = Obj.FromPassword; string subject = Obj.Subject; string body = "You’re receiving this message because you recently signed up for a Shopify account." + "Confirm your email address by clicking the button below.This step adds extra security to your business by verifying you own this email." + path + objemailvm.UserId; var smtp = new SmtpClient { Host = Obj.Host, // "smtp.gmail.com", Port = int.Parse(Obj.Port), EnableSsl = Obj.EnableSsl, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = Obj.UseDefaultCredentials, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); } }
public async Task <IActionResult> SendEmail([FromBody] EmailVM vm) { if (!ModelState.IsValid) { return(BadRequest()); } var errors = ""; var emailTasks = vm.To.Select(r => _emailSender.SendStandardEmailAsync( new EmailMessage { Name = r.Name, Email = r.Email, Subject = vm.Subject, Message = vm.Message })); try { await Task.WhenAll(emailTasks); } catch (Exception exc) { errors += exc.Message + Environment.NewLine; } var result = ""; if (errors == "") { result = "Epost sendt!"; } else { result = "Sendte epost. Men fikk noen feil: " + Environment.NewLine + errors; } return(Ok(result.Replace(Environment.NewLine, "<br />"))); }
public void SendEmail(EmailVM emailParameter) { //We find user which is logged now var user = UserManager.FindById(User.Identity.GetUserId()); var userEmail = user.Email; var userName = User.Identity.GetUserName(); //We create a email model which is send to email server MailAddress from = new MailAddress(userEmail, userName); MailAddress to = new MailAddress(emailParameter.To); MailMessage message = new MailMessage(from, to); message.Subject = emailParameter.Subject; message.Body = emailParameter.Body; //We create mailaddresses for ccusers like for "from" or "to" users for (int FirstCCUserNumber = 0; FirstCCUserNumber < emailParameter.CClist.Length; FirstCCUserNumber++) { MailAddress copy = new MailAddress(emailParameter.CClist[FirstCCUserNumber].Email); message.CC.Add(copy); } //We connect with email server SmtpClient mailer = new SmtpClient("127.0.0.1", 25); //We read password of our user from cookie - this cookie is created when the user is logged to application string PasswordCookie = Request.Cookies["PasswordCookie"].Value; mailer.Credentials = new NetworkCredential(userEmail, PasswordCookie); //mailer.EnableSsl = true; mailer.EnableSsl = false; mailer.Send(message); // we redirect to receive email when we was sended email Response.Redirect("~/Email/Receive/ReceiveEmail"); //return RedirectToAction("ReceiveEmail", "Receive");; }
public PartialViewResult EmailPartial(string DealerEmail) { EmailVM emailVM = new EmailVM { DealerEmail = DealerEmail }; return(PartialView("_EmailPartial", emailVM)); }
// // GET: /Confirmation/ public ActionResult EmailConfirmation(FormCollection collection) { EmailVM model = new EmailVM(); model = sessionManager.EmailDetails; return(View(model)); }
public ActionResult Update([DataSourceRequest] DataSourceRequest request, EmailVM obj) { if (ModelState.IsValid) { repository.SetLoggedUserId(Guid.Parse(User.Identity.GetUserId())); repository.EmailUpdate(obj); } return(Json(new[] { obj }.ToDataSourceResult(request, ModelState))); }
/// <summary> /// Private method to merge in the model /// </summary> /// <returns></returns> private EmailVM GetUpdatedModel() { EmailVM model = new EmailVM(); model = sessionManager.EmailDetails; bool result = TryUpdateModel(model); return(model); }
public async Task PostAsync([FromBody] EmailVM emailVM) { try { await EmailServices.SendMail(emailVM); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> checkEmail(EmailVM email) { try { return(NotFound()); } catch (Exception xcp) { //log exception return(new StatusCodeResult((int)HttpStatusCode.InternalServerError)); } }
public IActionResult Post([FromBody] EmailVM emailVM) { var emailBD = Mapper.Map <Email>(emailVM); var email = _emailService.Enviar(emailBD); if (email != null) { return(Ok(email)); } return(Ok()); }
public async Task <int> SendMail(EmailVM obj, string path) { try { var mail = GetEmailSettings(); MessagingService.SendMailAsync(mail, obj, path); return(await Task.FromResult <int>(1)); } catch (Exception ex) { throw ex; } }
public IActionResult SendEmail(int ClanID, int TeretanaID) { Clan clan = db.Clan.Where(c => c.ClanID == ClanID).FirstOrDefault(); EmailVM vm = new EmailVM() { Ime = clan.Ime, Email = clan.Email, Naslov = "Napomena", TeretanaID = TeretanaID }; return(PartialView(vm)); }
public async Task <Response> Send(EmailVM email) { var apiKey = Environment.GetEnvironmentVariable("SendGridKey"); var client = new SendGridClient(apiKey); var from = new EmailAddress("*****@*****.**", "Example User"); var subject = email.Subject; var to = new EmailAddress(email.ToEmail, "Example User"); var plainTextContent = email.Message; var htmlContent = "<strong>Cheers...</strong>"; var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent); var response = await client.SendEmailAsync(msg); return(response); }
public ActionResult SendEmail() { var model = new EmailVM(); model.LineManagerEmailAddressList = new List <string>(); model.IncidentItem = sessionManager.CurrentIncident; model.ManagerFirstName = model.IncidentItem.ManagerFirstName; model.ManagerLastName = model.IncidentItem.ManagerLastName; model.NominatedManager = sessionManager.NominatedManager; model.NominatedManagerEmailAddress = sessionManager.NominatedManagerEmailAddress; model.Message = "Incident ID " + model.IncidentItem.IncidentID + " Created"; sessionManager.EmailDetails = model; return(View(model)); }
public async Task <ActionResult> SendAsync([FromBody] EmailVM email) { if (!ModelState.IsValid) { _response.Message = "Please provide all required data for sign up."; return(BadRequest(_response)); } var result = await _emailService.Send(email); if (result.StatusCode == System.Net.HttpStatusCode.Accepted) { return(Ok(_response)); } return(BadRequest(_response)); }
public async Task <HttpResponseMessage> SendMail(EmailVM obj) { try { var path = System.Configuration.ConfigurationManager.AppSettings["ActivationPath"]; string username = RequestContext.Principal.Identity.Name; string clientAddress = HttpContext.Current.Request.UserHostAddress; var itemsz = await corepo.SendMail(obj, path); return(Request.CreateResponse(HttpStatusCode.OK, itemsz)); } catch (Exception ex) { LogHelper.WriteLog(HttpContext.Current.Request, ex, RequestContext.Principal.Identity.Name); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public JsonResult SendEmailToUser(EmailVM emailObj) { JsonResult resultError = new JsonResult(); if (ModelState.IsValid) { string emailBody = emailObj.Message.Replace("\n", "<br />"); bool result = false; result = SendEmail(emailObj.Email, emailObj.Subject, emailBody); return(Json(new { Success = result }, JsonRequestBehavior.AllowGet)); } else { resultError.Data = new { Success = false, Error = "Unable to send. Please enter valid values." }; return(resultError); } }
public IActionResult SendMail([FromBody] EmailVM emailVM) { try { if (emailVM.Email == null) { return(BadRequest(new { message = "object cannot be null" })); } _emailService.SendEmail(emailVM.Email, emailVM.Subject, emailVM.Body); return(Ok(new { message = "mail sent successfully" })); } catch (Exception) { return(this.StatusCode(500)); } }
public async Task <IActionResult> GetAll([FromQuery] EmailVM emailVM) { var doctor = await getCurrentUser(); var patient = (Patient)doctor.RelatedUsers.FirstOrDefault(u => u.UserName == emailVM.Email); if (patient != null) { patient = await uw.Repository <Patient>() .GetAsync(p => p.UserName == patient.UserName, p => p.Prescriptions); var prescVMs = mapper.Map <IEnumerable <PrescriptionVM> >(patient.Prescriptions); return(Ok(prescVMs)); } return(NotFound(new ValidationError( ErrorType.UnexpectedError, "There is no such a patient to retrieve data!" ))); }
public ActionResult SendEmail(EmailVM emailVM) { try { if (ModelState.IsValid) { var senderEmail = new MailAddress("Put Your Email", "Cars For Sale"); //Put your Email, will send by it var receiverEmail = new MailAddress(emailVM.DealerEmail, "Receiver"); var password = "******"; //Put your Password var sub = emailVM.Subject; var body = "Client Name : " + emailVM.Name + "<br>" + "Client Email : " + emailVM.ClientEmail + "<br>" + "Client Phone : " + emailVM.Phone + "<br>" + "Client Message : " + emailVM.Body + "<br>"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(senderEmail.Address, password) }; using (var mess = new MailMessage(senderEmail, receiverEmail) { Subject = sub, Body = body }) { mess.IsBodyHtml = true; smtp.Send(mess); } return(RedirectToAction("Cars")); } } catch (Exception) { ViewBag.Error = "Some Error"; } return(RedirectToAction("Cars")); }
public static async Task SendMail(EmailVM emailVM) { var client = new SendGridClient(""); var msg = new SendGridMessage(); msg.SetFrom(new EmailAddress(emailVM.OriginSenderEmail, emailVM.OriginSenderName)); var recipients = new List <EmailAddress> { //new EmailAddress("*****@*****.**") new EmailAddress("") }; msg.AddTos(recipients); msg.SetSubject(emailVM.EmailSubject); msg.AddContent(MimeType.Html, "<p>" + emailVM.EmailBody + "</p>"); var response = await client.SendEmailAsync(msg); }
public List <IOSCartVM> IOSShowCart([FromBody] EmailVM email) { //return "karlsb"; // return email; List <AccountGood> accountGoods = _context.AccountGoods.Where(ag => ag.Account_ID == _context.Users.Where(name => name.Email == email.Email).Select(i => i.Id).FirstOrDefault() && ag.Type == "cart").ToList(); List <IOSCartVM> myCart = new List <IOSCartVM>(); // //return accountGoods.Count; foreach (AccountGood accountGood in accountGoods) { IOSCartVM oneGood = new IOSCartVM { goodId = accountGood.Goods_ID, goodName = _context.Goodses.Where(gn => gn.goods_id == accountGood.Goods_ID).Select(gn => gn.goods_name).FirstOrDefault(), quantity = accountGood.Quantity }; myCart.Add(oneGood); } return(myCart); }
public async Task <IActionResult> Delete([FromQuery] EmailVM emailVM) { var user = await getCurrentUser(); var relatedUser = user.RelatedUsers.Where(u => u.UserName == emailVM.Email).FirstOrDefault(); if (relatedUser != null) { user.RelatedUsers.Remove(relatedUser); await uw.Save(); await notifyHub.NotifyIfConnected(relatedUser.Id, user, NotifyState.OnRelationDeleted); return(NoContent()); } return(NotFound(new ValidationError( ErrorType.UnexpectedError, "There is no such a user to delete!" ))); }
public void Update(EmailVM vm) { email.Id = vm.Id; email.StatusID = vm.StatusId; email.From = vm.From; email.To = vm.To; email.Date = vm.Date; email.DateBack = vm.DateBack; email.Description = vm.Description; email.DeliverySystem = vm.DeliverySystem; email.TrackingNumber = vm.TrackingNumber; email.TrackingNumberBack = vm.TrackingNumberBack; try { rep.Update(email); } catch { } }