Example #1
0
 public bool Email(EmailModel emailModel)
 {
     var model = new SupportModel();
     //return Redirect("/");
    // return View(model);
     return model.sendMail(emailModel);
 }
Example #2
0
        public bool sendMail(EmailModel emailModel)
        {
            MailMessage mail = new MailMessage();
            SmtpClient client = new SmtpClient();
            client.Port = 587;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Host = "smtp.gmail.com";
            mail.To.Add(new MailAddress("*****@*****.**"));
            mail.From = new MailAddress("*****@*****.**");
            client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "haythamfaraz");
            mail.Subject = "test subject";
            client.EnableSsl = true;
            mail.IsBodyHtml = true;
            mail.Body = "<html>"
+ "<body>"
 + "<div> <h2>Email: " + emailModel.Email + " </h2> </br>"
 + "<h2> Name: " + emailModel.Name + "</h2> </br>" +
 "<h2> Phone number: " + emailModel.PhoneNumber + "</h2> </br>" +
 "<h2> More Information: " + emailModel.Message+ "</h2> </br>" 
 + "</div>"
 + "</body>"
 + "</html>";
            try
            {
                client.Send(mail);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }