Пример #1
0
        private static void SendMail(MailModel mailModel)
        {
            if (mailModel.Name == null && mailModel.Email == null) return;

            var message = new MailMessage { From = new MailAddress(Sharpmindswebmail) };
            message.To.Add(new MailAddress(Sharpmindsemail));
            message.Subject = mailModel.Subject.Equals(String.Empty) ? "No subject added" : mailModel.Subject;
            message.Body = string.Format("A website visitor has contacted us: \n\n" +
                                     "Name:    \t{0} \n" +
                                     "Phone:   \t{1} \n" +
                                     "E-mail:  \t{2} \n" +
                                     "Subject: \t{3} \n" +
                                     "Message: \t{4} \n",
                                     mailModel.Name, mailModel.Phone, mailModel.Email, mailModel.Subject, mailModel.Message);

            /* UnoEuro local client */
            var client = new SmtpClient("smtp.unoeuro.com", 25);
            #if DEBUG
            client = new SmtpClient("asmtp.unoeuro.com", 8080)
            {
                Credentials = new NetworkCredential("*****@*****.**", "9h13kt")
            };
            #endif
            client.Send(message);
            client.Dispose();
            mailModel.MailSent = true;
        }
Пример #2
0
 public ActionResult _MessageModal(MailModel mailModel)
 {
     if (ModelState.IsValid)
     {
         mailModel.MailSent = true;
         SendMail(mailModel);
     }
     return Redirect("~/");
 }