예제 #1
0
        //[ValidateAntiForgeryToken]
        public async Task Contact(EmaiViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var from  = model.FromEmail;
                    var email = new MailMessage(from, ConfigurationManager.AppSettings["emailto"])
                    {
                        Subject    = model.Subject,
                        Body       = $"<strong>{model.FromName}</strong> left message:  {model.Body}.  The user's email address is <strong>{model.FromEmail} </strong>",
                        IsBodyHtml = true
                    };
                    var svc = new PersonalEmail();
                    await svc.SendAsync(email);

                    //ViewBag.Message = "Email has been sent";
                    //return View();
                    //return File("~/contact.html", "text/html");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    await Task.FromResult(0);
                }
            }

            //return File("~/contact.html", "text/html");
        }
예제 #2
0
 //[ValidateAntiForgeryToken]
 public async Task SignIn(EmaiViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var from  = model.FromEmail;
             var email = new MailMessage(from, ConfigurationManager.AppSettings["emailto"])
             {
                 Subject    = model.Subject,
                 Body       = $"<strong>{model.FromName}</strong> left message:  {model.Body}.  The user's email address is <strong>{model.FromEmail} </strong>",
                 IsBodyHtml = true
             };
             var svc = new PersonalEmail();
             await svc.SendAsync(email);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             await Task.FromResult(0);
         }
     }
 }