//[Authorize]
        public async Task <ActionResult> Contact(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                for (int i = 0; i < model.ToEmail.Length; i++)
                {
                    //message.To.Add(new MailAddress(model.ToEmail[i]));
                }
                message.To.Add(new MailAddress(model.ToEmail));                  // replace with valid value
                message.From       = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject    = "Congrats on the achievement";
                message.Body       = string.Format(body, model.FromName, model.ToEmail, model.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
Beispiel #2
0
        public async Task <ActionResult> Contact(EmailFormModel model, string sayi) // statik oluşturacak metodu yazdık!
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>EntryCode: {0} </p>";
                var message = new MailMessage();



                message.To.Add(new MailAddress(model.FromEmail));                             // replace with valid value
                message.From       = new MailAddress("*****@*****.**");                // replace with valid value
                message.Subject    = "Securty Code";
                message.Body       = string.Format(body, Randomsayi(sayi)); /*model.Message*/ // random sayi cağırdık!
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient()) // bu kısım nerden gönderilcek ile ilgili
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // geçerli mail adresi ile değiştirin // cahange your Email!
                        Password = "******"          // geçerli şifre ile değiştirin // change your pass!
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp-mail.outlook.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }

            return(View(model));
        }
Beispiel #3
0
        public async Task <ActionResult> SendEmail(EmailFormModel emailModel, ReportView ReportModel)
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>11/28/2016</p><p>Dear Council Person,</p><p>Following are concerns submitted by citizens on citizenconnect.com.</p><p> For the week of November 28 - December 4: </p><p>- There have been 14 reported incidents of street light outtages. Please click *here* to view the location.</p><p>- There have been 19 reports of potholes. Please click *here* to view the location.</p><p></p><p>Thank you for prompt attention to these concerns. We apprecite the time and effort each of you take in making Cleveland a great place to live.</p><p></p><p>Sincerely,</p><p>Citizen Connect Administration</p>";
                var message = new MailMessage();
                message.Bcc.Add(new MailAddress("*****@*****.**"));     // replace with valid value
                message.Bcc.Add(new MailAddress("*****@*****.**"));
                message.From       = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject    = "Weekly Reports From Citizen Connect";
                message.Body       = string.Format(body);
                message.IsBodyHtml = true;
                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"                   // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(emailModel));
        }
Beispiel #4
0
        public ActionResult Enviar(EmailFormModel model)
        {
            var mensaje = "";

            if (ModelState.IsValid)
            {
                var message = new MailMessage();
                message.To.Add(new MailAddress(model.FromEmail)); // Mail destinatario
                message.Subject    = model.FromSubject;           // Asunto
                message.Body       = model.Message;               // mensaje
                message.IsBodyHtml = true;

                try
                {
                    var smtp = new SmtpClient();
                    smtp.Send(message);

                    mensaje = "Email has been sent successfully.";
                }
                catch (Exception ex)
                {
                    mensaje = "ERROR: " + ex.Message;
                }
            }

            ViewBag.mensaje = mensaje;
            return(View("/Views/Panel/Mensaje.cshtml"));
        }
Beispiel #5
0
        public static async Task SendEmail(EmailFormModel emailForm)
        {
            var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
            var message = new MailMessage();

            message.To.Add(new MailAddress(emailForm.ToEmail));          // replace with valid value
            message.From    = new MailAddress("*****@*****.**"); // replace with valid value
            message.Subject = emailForm.Subject;

            message.Body       = string.Format(body, emailForm.FromName, emailForm.FromEmail, emailForm.Message);
            message.IsBodyHtml = true;

            using (var smtp = new SmtpClient())
            {
                var credential = new NetworkCredential
                {
                    UserName = "******", // replace with valid value
                    Password = "******"           // replace with valid value
                };
                smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = credential;
                smtp.Host      = "smtp.gmail.com";
                smtp.Port      = 587;
                smtp.EnableSsl = true;
                await smtp.SendMailAsync(message);
            }
        }
        public JsonResult SendEmail(EmailFormModel model)
        {
            var message = new MimeMessage();

            message.From.Add(new MailboxAddress("QA Ingenieros Ltda", "*****@*****.**"));
            message.To.Add(new MailboxAddress(model.ToName, model.ToEmail));
            message.Subject = model.Subject;

            // message.Body = new TextPart ("plain") {
            //  Text = model.Message
            // };
            var filePath = "wwwroot/Reports/" + model.Attach;
            //Fetch the attachments from db
            //considering one or more attachments
            var builder = new BodyBuilder {
                TextBody = model.Message
            };

            builder.Attachments.Add(filePath);
            message.Body = builder.ToMessageBody();

            using (var client = new SmtpClient()){
                client.Connect("mail.qaingenieros.com", 587, false);

                // Note: only needed if the SMTP server requires authentication
                client.Authenticate("*****@*****.**", "qa4673008");

                client.Send(message);
                client.Disconnect(true);
            }

            return(new JsonResult(new { Status = "Success" }));
        }
        public async Task <ActionResult> Contact(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress("*****@*****.**"));
                message.From       = new MailAddress("*****@*****.**");
                message.Subject    = "Your email subject";
                message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
                message.IsBodyHtml = true;
                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******",
                        Password = "******"
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
        public async Task <ActionResult> Email(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var body = "";
                body += "<p>From: {0} ({1})</p>";
                body += "<p>Message:</p>";
                body += "<hr>";
                body += "<p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress("*****@*****.**")); //Send to this e-mail address
                message.Subject    = "invition";
                message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
                message.IsBodyHtml = true;
                using (var smtp = new SmtpClient())
                {
                    try
                    {
                        await smtp.SendMailAsync(message);

                        return(RedirectToAction("Sent"));//Goto sent successful page.
                    }
                    catch (Exception e)
                    {
                        Response.Write("<p>" + e.Message + "</p>");
                    }
                    return(View());//Send back to form if unsuccessful
                }
            }
            return(View(model));
        }
Beispiel #9
0
        public async Task <ActionResult> AutoReply(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var message = new MailMessage();
                message.To.Add(new MailAddress(model.FromEmail));
                message.From    = new MailAddress("*****@*****.**");
                message.Subject = "Automatic Reply, Please don't reply to this message";
                message.Body    = string.Format("Thank you! for contacting us. We received your message at " + DateTime.Now +
                                                " and will reply as soon as we can depending on the message we received. Sorry, for the inconvenince." +
                                                " If you need immediate help, don't forget to call us on our direct hotline.");
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"                    // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);
                }
            }
            return(View(model));
        }
Beispiel #10
0
        public async static Task <string> SendMailReminder(EmailFormModel model)
        {
            var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
            var message = new MailMessage();

            message.To.Add(new MailAddress("*****@*****.**"));     // replace with valid value
            message.From       = new MailAddress("*****@*****.**"); // replace with valid value
            message.Subject    = "Your email subject";
            message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
            message.IsBodyHtml = true;

            using (var smtp = new SmtpClient())
            {
                var credential = new NetworkCredential
                {
                    UserName = "******", // replace with valid value
                    Password = "******"            // replace with valid value
                };
                smtp.Credentials = credential;
                smtp.Host        = "smtp.gmail.com";
                smtp.Port        = 587;
                smtp.EnableSsl   = true;
                await smtp.SendMailAsync(message);

                return("conplete");
            }
        }
Beispiel #11
0
        public async Task <JsonResult> Recover(string email)
        {
            var _login = _usuarioRepo.GetAsync().Result.FirstOrDefault(x => x.EmailUsuario == email);

            if (_login != null)
            {
                int userId = Convert.ToInt32(_login.IdUsuario);

                var _userToSend = new EmailFormModel()
                {
                    FromEmail = email,
                    FromName  = _login.NmUsuario
                };

                // Credenciais para o envio do email
                var credentials = _credential.GetEmailCredentials();

                var credEmail = credentials.Where(k => k.Key == "Email").Select(e => e.Value).ToList().FirstOrDefault();
                var credPass  = credentials.Where(k => k.Key == "Password").Select(e => e.Value).ToList().FirstOrDefault();
                var credHost  = credentials.Where(k => k.Key == "Host").Select(e => e.Value).ToList().FirstOrDefault();
                var credPort  = credentials.Where(k => k.Key == "Port").Select(e => e.Value).ToList().FirstOrDefault();

                var _sender = new Sender(credEmail, credPass, credHost, Convert.ToInt16(credPort));

                // Envia email para recuperação de senha
                await _sender.SendRecover(_userToSend, userId);

                return(Json(new { status = true }));
            }

            return(Json(new { error = true }));
        }
Beispiel #12
0
        public async Task <ActionResult> Contact(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var body = "<p>Email From: ({0})</p><p>Message:</p><p>{1}</p>";
                //var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress("*****@*****.**")); // replace with valid value
                message.From       = new MailAddress("*****@*****.**");  // replace with valid value
                message.Subject    = "Demande de contact - Site web VenteEnchere";
                message.Body       = string.Format(body, model.FromEmail, model.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"                // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
Beispiel #13
0
        public async Task <ActionResult> QuoteDecline(int Id)
        {
            var WeedHackSesh   = System.Web.HttpContext.Current.Request.Cookies["WeedHackersSession"].Value;
            var UserDetails    = MvcApplication.Sessions[WeedHackSesh].User;
            var serviceRequest = WeedHackersContext.ServiceRequests
                                 .Include(sa => sa.ServiceAdvisor.User)
                                 .Single(sr => sr.Id == Id);

            var emailmodel = new EmailFormModel
            {
                Message   = UserDetails.Name + " " + UserDetails.Surname + " has declined Quote #" + serviceRequest.Id + " issued to him <br/>",
                Recipient = serviceRequest.ServiceAdvisor.User.Email
            };

            var ServiceRequestStatus = new ServiceRequestStatusUpdate
            {
                ServiceRequestId = serviceRequest.Id,
                ServiceStatusId  = WeedHackersContext.ServiceStatuses.Single(s => s.Name == "Rejected").Id,
                Message          = "Service Requested has been rejected",
            };

            WeedHackersContext.ServiceRequests.AddOrUpdate(sr => sr.Id, serviceRequest);
            WeedHackersContext.ServiceRequestStatusUpdates.Add(ServiceRequestStatus);

            await WeedHackersContext.SaveChangesAsync();

            var email = new EmailHelper();
            await email.SendEmail(emailmodel);

            FlashMessage.Confirmation("Quote Rejected", "");
            return(RedirectToAction("QuotesReceived", "Customer"));
        }
        public ActionResult Email(EmailFormModel email)
        {
            var message = new MimeMessage();

            message.From.Add(new MailboxAddress("test", "*****@*****.**"));
            message.To.Add(new MailboxAddress("Pranay", "*****@*****.**"));
            message.Subject = "hi";
            message.Body    = new TextPart("plain")
            {
                Text = "will this worku?"
            };

            using (var client = new SmtpClient())
            {
                //client.Connect("smtp.example.com", 587, false);
                //client.AuthenticationMechanisms.Remove("XOAUTH2");

                client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                client.Connect("smtp.gmail.com", 587, false);

                client.AuthenticationMechanisms.Remove("XOAUTH2");
                client.Authenticate("mygoogleusername", "mygooglepassword");

                client.Send(message);
                client.Disconnect(true);
            }



            return(RedirectToAction("Index"));
        }
Beispiel #15
0
        public async static Task<string> SendMailReminder(EmailFormModel model)
        {
                var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress("*****@*****.**"));  // replace with valid value 
                message.From = new MailAddress("*****@*****.**");  // replace with valid value
                message.Subject = "Your email subject";
                message.Body = string.Format(body, model.FromName, model.FromEmail, model.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******",  // replace with valid value
                        Password = "******"  // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host = "smtp.gmail.com";
                    smtp.Port = 587;
                    smtp.EnableSsl = true;
                    await smtp.SendMailAsync(message);
                    return "conplete";
                }
        }
Beispiel #16
0
        public ActionResult Contact(string message, EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                string       body         = String.Format("Email from customer: {0}\n{1}\nMessage:\n{2}", model.FromName, model.FromEmail, model.Message);
                var          fromAddress  = new MailAddress("*****@*****.**", "From Me");
                var          toAddress    = new MailAddress("*****@*****.**", "To Me");
                const string fromPassword = "******";
                const string subject      = "Email from customer";

                var smtp = new SmtpClient
                {
                    Host                  = "smtp.gmail.com",
                    Port                  = 587,
                    EnableSsl             = true,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
                };
                using (var msg = new MailMessage(fromAddress, toAddress)
                {
                    Subject = subject,
                    Body = body
                })
                {
                    smtp.Send(msg);
                    ViewBag.Message = "Thanks, we got it!";
                    return(PartialView("_ContactThanks"));
                }
            }
            return(View());
        }
Beispiel #17
0
        public ActionResult ContactAsync(EmailFormModel model)
        {
            ViewBag.IsIndexHome = false;
            if (ModelState.IsValid)
            {
                var subject     = "AskYourMechanicDon.com Contact Form Email";
                var body        = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var fromAddress = model.FromEmail;
                var toAddress   = "[email protected];[email protected]";
                var emailBody   = string.Format(body, model.FromName, model.FromEmail, model.Message);

                var smtp = new SmtpClient();
                {
                    smtp.Host           = "smtp.askyourmechanicdon.com";
                    smtp.Port           = 587;
                    smtp.EnableSsl      = false;
                    smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                    smtp.Credentials    = new NetworkCredential("*****@*****.**", "TtLUVAz5");
                    smtp.Timeout        = 20000;
                }

                smtp.Send(fromAddress, toAddress, subject, emailBody);
                return(RedirectToAction("Sent"));
            }
            else
            {
                return(View());
            }
        }
Beispiel #18
0
        public async Task <ActionResult> Contact(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress(model.FromEmail));
                message.From       = new MailAddress("*****@*****.**");
                message.Subject    = "Your email subject";
                message.Body       = string.Format(body, model.CustomerName, model.FromEmail, model.PhoneNum, model.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******",                                                               // replace with valid value
                        Password = "******" // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.sendgrid.net";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
Beispiel #19
0
        public async Task <ActionResult> Contact(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress("*****@*****.**"));    // replace with valid value
                message.From       = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject    = "Your email subject";
                message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"                   // replace with valid value
                    };
                    smtp.Credentials           = credential;
                    smtp.Host                  = "smtp.gmail.com";
                    smtp.Port                  = 587;
                    smtp.EnableSsl             = true;
                    smtp.UseDefaultCredentials = false;
                    smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
Beispiel #20
0
        public async Task <ActionResult> Contact(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                // assemble message
                MailMessage message = new MailMessage();
                message.Subject = "Daily Report";
                message.Body    = "tbd: Aggregated form data";
                message.From    = new MailAddress("****@****.com"); // sender's email address
                message.To.Add("****@****.com");                    //  To: replace with instructor email address
                message.To.Add("****@****.com");                    //  Cc: replace with email of logged-in user

                // create & send SMTP email object containing message
                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {   // Gmail smtp login - replace w valid account info
                        UserName = "******",
                        Password = "******"
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
Beispiel #21
0
 public ActionResult Contact(EmailFormModel model)
 {
     if (ModelState.IsValid)
     {
         var senderEmail   = new MailAddress("*****@*****.**", "werenumber1");
         var receiverEmail = new MailAddress("*****@*****.**", "Receiver");
         var password      = "******";
         var body          = model.Message.ToString();
         var smtp          = new SmtpClient
         {
             Host                  = "smtp.gmail.com",
             Port                  = 587,
             EnableSsl             = true,
             DeliveryMethod        = SmtpDeliveryMethod.Network,
             UseDefaultCredentials = false,
             Credentials           = new NetworkCredential(senderEmail.Address, password)
         };
         using (var mess = new MailMessage(senderEmail, receiverEmail)
         {
             Subject = "From RANK",
             Body = "Customer's email: " + model.FromEmail + "\n" + "Message: " + body
         })
         {
             smtp.Send(mess);
         }
     }
     return(RedirectToAction("Email", new { email = "*****@*****.**", name = model.FromName }));
 }
Beispiel #22
0
        public async Task <ActionResult> Contact(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                //build message
                var body = "<p>Email From: {0} ({1})</p>" +
                           "<p>Message:</p>" +
                           "<p>{2}</p>";
                var message = new MailMessage();
                message.From = new MailAddress("*****@*****.**");       //sender
                message.To.Add(new MailAddress("*****@*****.**")); //receiver
                message.Subject    = "Test email MVC";
                message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
                message.IsBodyHtml = true;

                //smtp client - sender mail server setup
                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******",
                        Password = "******"
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("EmailSent"));
                }
            }
            return(View(model));
        }
Beispiel #23
0
        public void Parse_Null_Empty()
        {
            var formModel = new EmailFormModel();
            var email     = Email.Parse(formModel);

            Assert.Equal(Email.Empty(), email);
        }
Beispiel #24
0
        public ActionResult Email(string email)
        {
            EmailFormModel model = new EmailFormModel();

            model.ToEmail = email;
            return(View());
        }
        public async Task <ActionResult> Contact(EmailFormModel model, string toEmail)
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                toEmail = model.ToEmail;
                //message.To.Add(new MailAddress("*****@*****.**"));  // replace with valid value
                message.To.Add(toEmail);
                message.From       = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject    = "Your email subject";
                message.Body       = string.Format(body, model.FromName, model.FromEmail, model.ToEmail, model.Message);
                message.IsBodyHtml = true;
                if (model.Upload != null && model.Upload.ContentLength > 0)
                {
                    message.Attachments.Add(new Attachment(model.Upload.InputStream, Path.GetFileName(model.Upload.FileName)));
                }
                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"               // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp-mail.outlook.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
Beispiel #26
0
        public async Task <ActionResult> PrayerRequest(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress("*****@*****.**"));              // replace with valid value
                message.From       = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject    = "Prayer Request";
                message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"                         // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
        public async Task <ActionResult> OQueDoar(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var email   = model.Email;
                var body    = "<p>Email From: {0} ({1})</p><p>Assunto: O que Doar?</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();

                message.To.Add(new MailAddress(model.FromEmail));
                message.Bcc.Add(new MailAddress("*****@*****.**"));     // replace with valid value

                message.From       = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject    = model.Subject;
                message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******",      // replace with valid value
                        Password = _configuration["PasswordEmail"] // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "	smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
Beispiel #28
0
        public ActionResult SendMessage(EmailFormModel model)
        {
            var          fromAddress  = new MailAddress("*****@*****.**", "Daniel Ferreira");
            var          toAddress    = new MailAddress("*****@*****.**", "Daniel Ferreira");
            string       fromPassword = System.Configuration.ConfigurationManager.AppSettings["autoMailPass"];
            const string subject      = "Portfolio contact";
            string       body         = "Nome: " + model.Name + " || Email: " + model.Email + " || Message: " + model.Message;

            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            {
                smtp.Send(message);
            }

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Contact(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress("*****@*****.**"));      // replace with valid value
                message.From       = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject    = "OUt of inventory";
                message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"                    // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp-mail.outlook.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
        public async Task <ActionResult> Authorize(EmailFormModel model) //handles authorize user email and form filling
        {
            if (ModelState.IsValid)
            {
                var body    = "<p>Email From: {0} ({1})</p><p>Here is your link to register!</p><p>{2}</p>";
                var message = new MailMessage();
                message.To.Add(new MailAddress(model.FromEmail));                // replace with valid value
                message.From    = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject = "TLDR Order Form Registration";
                // Get url for registration
                var url = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, "/Account/Register");
                message.Body       = string.Format(body, "TLD Admin", "*****@*****.**", "Registration Link: " + url);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"                    // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);

                    return(RedirectToAction("Sent"));
                }
            }
            return(View(model));
        }
        public async Task <ActionResult> Contact(EmailFormModel model)
        {
            //var name = Request["name"].ToString();
            //var Email = Request["toemail"].ToString();
            //var body = Request["comments"].ToString();
            //var message = new MailMessage();
            var body    = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
            var message = new MailMessage();

            message.To.Add(new MailAddress("*****@*****.**"));    // replace with valid value
            message.From       = new MailAddress("*****@*****.**"); // replace with valid value
            message.Subject    = "Comments about site";
            message.Body       = string.Format(body, model.FromName, model.FromEmail, model.Message);
            message.IsBodyHtml = true;
            using (var smtp = new SmtpClient())
            {
                var credential = new NetworkCredential
                {
                    UserName = "******", // replace with valid value
                    Password = "******"                // replace with valid value
                };
                smtp.Credentials = credential;
                smtp.Host        = "smtp.gmail.com";
                smtp.Port        = 587;
                smtp.EnableSsl   = true;
                await smtp.SendMailAsync(message);

                return(RedirectToAction("Sent"));
            }
        }
Beispiel #32
0
 static void Main(string[] args)
 {
     EmailFormModel model=new EmailFormModel();
     model.FromName = "Server";
     model.FromEmail = "*****@*****.**";
     model.Message = "Reminding operation.this is test message." + DateTime.Now.ToShortTimeString();
     Task t = SendMailReminder(model);
     t.ContinueWith((str) =>
     {
         Console.WriteLine(str.Status.ToString());
     });
     
     t.Wait();
 }