Example #1
0
        private void SendEmail(EmailFormModel model, string userEmail)
        {
            if (ModelState.IsValid)
            {
                var          fromAddress  = new MailAddress("*****@*****.**", "Deniaa forum");
                var          toAddress    = new MailAddress(userEmail, "Dear user");
                const string fromPassword = "******";
                const string subject      = "Confirme your email";
                const string body         = "Email From: {0} ({1})Message: {2}";

                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 = string.Format(body, model.FromName, model.FromEmail, model.Message)
                })
                {
                    smtp.Send(message);
                }
            }
        }
	    private void SendEmail(EmailFormModel model, string userEmail)
	    {
		    if (ModelState.IsValid)
		    {



			    var fromAddress = new MailAddress("*****@*****.**", "Deniaa forum");
			    var toAddress = new MailAddress(userEmail, "Dear user");
			    const string fromPassword = "******";
			    const string subject = "Confirme your email";
			    const string body = "Email From: {0} ({1})Message: {2}";

			    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 = string.Format(body, model.FromName, model.FromEmail, model.Message)
			    })
			    {
				    smtp.Send(message);
			    }
		    }
	    }