Exemplo n.º 1
0
        public ActionResult EmailFriend(EmailFriendModel model)
        {
            if (ModelState.IsValid)
            {
                string body = System.IO.File.ReadAllText(Server.MapPath("~/Template") + "/friendemail.html");
                body = string.Format(body, "<a href='" + ConfigurationManager.AppSettings["baseURL"].ToString() + "/Jobs/JobDescription/" + model.JobReference + ".shtml' >" + model.JobTitle + "</a>", "<a href='" + model.YourEmail + "' >" + model.YourEmail + "</a>");
                MailMessage message = new MailMessage
                {
                    From = new MailAddress(model.YourEmail),
                    Subject = "Take a look at this great job",
                    Body = body,
                    IsBodyHtml = true
                };
                message.To.Add(model.FriendEmail);
                SmtpClient sc = new SmtpClient();
                sc.Host = ConfigurationManager.AppSettings["smtpHost"].ToString();
                string smtpUser = ConfigurationManager.AppSettings["smtpUserName"].ToString();
                string smtpPwd = ConfigurationManager.AppSettings["smtpPassword"].ToString();
                sc.Credentials = new System.Net.NetworkCredential(smtpUser, smtpPwd);
                sc.Send(message);

                return base.View("EmailAFriendSuccess");
            }

            return base.View("EmailAFriend", model);
        }
Exemplo n.º 2
0
 public ActionResult EMailAFriend(int id, string title, string refe)
 {
     EmailFriendModel model = new EmailFriendModel();
     model.JobId = id;
     model.JobTitle = title;
     model.JobReference = refe;
     return base.View("EMailAFriend", model);
 }