Ejemplo n.º 1
0
        public ActionResult Send_Email(Vmodel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    String toEmail  = model.ToEmail;
                    String subject  = model.Subject;
                    String contents = model.Contents;
                    String fp       = model.FP;

                    EmailSender es = new EmailSender();
                    es.Send(toEmail, subject, contents, fp);

                    ViewBag.Result = "Email has been send.";

                    ModelState.Clear();

                    return(View(new Vmodel()));
                }
                catch
                {
                    return(View());
                }
            }

            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Contact(Vmodel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    String toEmail;
                    String subject;
                    String contents;
                    String cc;
                    String fp;
                    model.ToEmail  = Sanitizer.GetSafeHtmlFragment(model.ToEmail);
                    model.Subject  = Sanitizer.GetSafeHtmlFragment(model.Subject);
                    model.Contents = Sanitizer.GetSafeHtmlFragment(model.Contents);
                    model.Cc       = Sanitizer.GetSafeHtmlFragment(model.Cc);

                    EmailSender es = new EmailSender();
                    toEmail  = model.ToEmail;
                    subject  = model.Subject;
                    contents = model.Contents;
                    cc       = model.Cc;
                    fp       = model.FP;

                    if (toEmail.Contains(";") && cc == null)
                    {
                        string[] tocheckemail = toEmail.Split(';');
                        foreach (string newemail in tocheckemail)
                        {
                            _ = es.SendAsync(newemail, subject, contents, fp, cc);
                        }
                    }
                    else
                    {
                        _ = es.SendAsync(toEmail, subject, contents, fp, cc);
                    }
                    ViewBag.Result = "Email has been send.";

                    ModelState.Clear();

                    return(View(new Vmodel()));
                }
                catch
                {
                    return(View());
                }
            }

            return(View());
        }