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 = emailModel.name + " | " + emailModel.service;
        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> Service: " + emailModel.service + "</h2> </br>" +
"<h2> More Information: " + emailModel.message + "</h2> </br>"
+ "</div>"
+ "</body>"
+ "</html>";
        try
        {
            client.Send(mail);
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }
    protected void submit_Click(object sender, EventArgs e)
    {
        bool validForm = true;
        if (dropdownService.SelectedIndex == 0)
        {
            servicesError.Text = "Must select a service";
            validForm = false;
        }
        else
        {
            servicesError.Text = "";
        }
        if (!terms_checkbox.Checked)
        {
            checkboxError.Text = "Please accepts Terms and Conditions";
            validForm = false;
        }
        else
        {
            checkboxError.Text = "";
        }

        if (validForm)
        {
            var name = nameTextbox.Text;
            var email = emailTextBox.Text;
            var mobile = mobileTextbox.Text;
            var message = messageTextbox.Text;
            var service = dropdownService.SelectedValue;
            EmailModel emailModel = new EmailModel(email, mobile, name, message, service);
            SupportModel supportModel = new SupportModel();
            var emailSentSuccessfully = supportModel.sendMail(emailModel);
        }
       // if (emailSentSuccessfully)
       // {
           // emailTextBox.Visible = false;
           // mobileTextbox.Visible = false;
           // nameTextbox.Visible = false;
           // messageTextbox.Visible = false;
            //terms_checkbox.Visible = false;
         //   downloadLink.Visible = true;
            //termsAndCondition.Visible = false;
            //submitBtn.Visible = false;
            //configText.Visible = false;
          //  downloadLabel.Visible = true;
           // emailTitle.Visible = false;
           // nameTitle.Visible = false;
           // phoneNumberTitle.Visible = false;
           // messageTitle.Visible = false;
           // serviceLabel.Visible = false;
          //  dropdownService.Visible = false;
          //  CheckBoxRequired.Visible = false;
          //  MainHeader.Text = "Your request has been sent in! Sit back and relax! A representative will get in contact with you shortly, Expect a call to this number: " + mobileTextbox.Text;
          //  downloadLabel.Text = "Our agents to assist you soon. A link will be provided to allow agent to assist you once you receive a call \r\n.";

    //    }

    }
 public void Notify(string body, List<string> email)
 {
     var model = new EmailModel
     {
         Subject = "یکان پدیا",
         Body = body,
         EmailAddress = email
     };
     _emailAdapter.SendEmail(model);
 }
        public void SendEmail(EmailModel email)
        {
            dynamic sg = new SendGridAPIClient("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");

            Email from = new Email("*****@*****.**","Brilliant Engineering Ltd");
            String subject = email.Subject;
            Email to = new Email(email.EmailAddress);
            Content content = new Content("text/html", email.Body);
            Mail mail = new Mail(from, subject, to, content);

            dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
        }
Exemplo n.º 5
0
        public EmailModel EditEmail(EmailModel email)
        {
            IRepository<Email> emailRepo = UnitOfWork.Repository<Email>();

            Email emailToEdit = emailRepo.Query.SingleOrDefault(e => e.Id == email.Id);

            if (emailToEdit != null)
            {
                emailToEdit.Subject = email.Subject;
                emailToEdit.Body = email.Body;
                return emailRepo.Update(emailToEdit) != null ? email : null;
            }
            return null;
        }
Exemplo n.º 6
0
        public EmailModel CreateEmail(EmailModel email)
        {
            IRepository<Email> emailRepo = UnitOfWork.Repository<Email>();
            Email newMail = new Email
            {
                Subject = email.Subject,
                Body = email.Body
            };

            Email insertedEmail = emailRepo.Insert(newMail);

            if (insertedEmail != null)
            {
                email.Id = insertedEmail.Id;
                return email;
            }
            return null;
        }
Exemplo n.º 7
0
        public ActionResult Create(EmailEditCreateModel model)
        {
            if (ModelState.IsValid)
            {
                EmailModel blModel = new EmailModel
                {
                    Id = model.Id,
                    Subject = model.Subject,
                    Body = model.Body
                };

                EmailModel createdEmail = EmailService.CreateEmail(blModel);
                if (createdEmail != null)
                {
                    return RedirectToAction("Index", "Emails", new { id = createdEmail.Id });
                }
            }

            return View(model);
        }
Exemplo n.º 8
0
        public async Task <IActionResult> SendSMS([FromBody] EmailModel model)
        {
            String message = HttpUtility.UrlEncode("Hi, Saon here this is a sms from our twilio sms service, how is it?");

            using (var wb = new WebClient())
            {
                byte[] response = wb.UploadValues("https://api.textlocal.in/send/", new NameValueCollection()
                {
                    { "apikey", "5/esm/vq14I-BAkdonTsO7mBUIYpWxzQadKqYMKAM0" },
                    { "numbers", "918600411621" },
                    { "message", message },
                    { "sender", "TXTLCL" }
                });
                string result = System.Text.Encoding.UTF8.GetString(response);
                //return result;
            }

            //const string accountSid = "AC2dc6d27432a8d71ec567c0ddf99926fd";
            //const string authToken = "21216052d8108c6b88db99be246a7fee";

            //TwilioClient.Init(accountSid, authToken);

            //var message = MessageResource.Create(
            //    body: "Hi, Saon here this is a sms from our twilio sms service, how is it?",
            //    from: new Twilio.Types.PhoneNumber("+12566662902"),
            //    to: new Twilio.Types.PhoneNumber("+919886677508")
            //);
            var response1 = new GenericResponse <string>()
            {
                IsSuccess    = true,
                Message      = "SMS sent successfully.",
                ResponseCode = 200,
                Result       = "Success"
            };

            return(Ok(response1));
        }
        public async Task <ActionResult> Contact(EmailModel model)
        {
            var emailBody = new StringBuilder();

            emailBody.AppendLine("This is a message from your BugSquasher site. The name and the email of the contacting person is above.");
            emailBody.AppendLine("<br />");
            emailBody.AppendLine(model.Body);

            if (ModelState.IsValid)
            {
                try
                {
                    var body = "<p>Email From: <bold>{0}</bold> ({1})</p><p> Message:</p><p>{2}</p>";
                    var from = "BugSquasher<*****@*****.**>";
                    model.Body = emailBody.ToString();

                    var email = new MailMessage(from, ConfigurationManager.AppSettings["emailto"])
                    {
                        Subject    = "BugSquasher Contact Email",
                        Body       = string.Format(body, model.FromName, model.FromEmail, model.Body),
                        IsBodyHtml = true
                    };

                    var svc = new PersonalEmail();
                    await svc.SendAsync(email);

                    //TODO: Add a Sent view
                    return(View("Sent"));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    await Task.FromResult(0);
                }
            }
            return(View(model));
        }
Exemplo n.º 10
0
        public async Task <ActionResult> Contact(EmailModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var body = "<p> Email From: <bold>{0}</bold>" +
                               "({1})</p><p> Message:</p><p>{2}</p>";
                    //model.Body = "This is a message from your blog site. The name and" +
                    //             "the email of the contacting person is above.";

                    var svc = new EmailService();
                    var msg = new IdentityMessage()
                    {
                        Subject = "Contact From Portfolio Site",
                        Body    = string.Format(body, model.FromName, model.FromEmail,
                                                model.Body),
                        Destination = "*****@*****.**" //ADD YOUR PERSONAL EMAIL ADDRESS HERE!
                    };

                    await svc.SendAsync(msg);

                    return(View());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    await Task.FromResult(0);

                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }
Exemplo n.º 11
0
        public async Task <bool> CreateEmailModel(EmailModel emailModel)
        {
            try
            {
                var existing = await _emailData.GetEmailByEmail(emailModel.Email);

                var item = existing.FirstOrDefault();
                if (item != null)
                {
                    return(false);
                }

                var existingtemp = await _emailTempData.GetTempEmailByEmail(emailModel.Email);

                var itemtemp = existing.FirstOrDefault();
                if (itemtemp != null)
                {
                    return(false);
                }

                var saveEmailModel = new DbEmailModel
                {
                    Id          = emailModel.Id.ToString(),
                    Email       = emailModel.Email,
                    CreatedDate = emailModel.CreatedDate
                };

                await _emailData.SaveEmail(saveEmailModel);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 12
0
        public async Task <ActionResult> ContactAsync(EmailModel model)
        {
            try
            {
                var EmailAddress = WebConfigurationManager.AppSettings["EmailTo"];
                var emailFrom    = $"{model.From} <{EmailAddress}>";
                var FinalBody    = $"{model.Name} has sent you the following message: <br/> {model.Body} <hr/> {WebConfigurationManager.AppSettings["LegalText"]}";

                var email = new MailMessage(emailFrom, EmailAddress)
                {
                    Subject    = model.Subject,
                    Body       = FinalBody,
                    IsBodyHtml = true
                };
                var emailSvc = new EmailService();
                await emailSvc.SendAsync(email);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                await Task.FromResult(0);
            }
            return(View(new EmailModel()));
        }
Exemplo n.º 13
0
        // Send email to change password for user
        public void ForgetPsswordEmail(PasswordForget changing)
        {
            try
            {
                EmailModel emailModel = new EmailModel();
                emailModel.toname  = "Client";
                emailModel.toemail = changing.Email;
                emailModel.subject = "No Reply: Password Reset Request! ";
                var url = changing.Link;
                emailModel.message =
                    "<div style='Text-align:center;background-color:#f9fbfd'>"
                    + "<img src='https://i.ibb.co/6g1vBwY/logo-text.png' alt='logo'/>"
                    + "<h2> Dear Client, </h2>"
                    + "<h4> You recently requested to reset your password for your account. Click the link below to reset it.</h4>"
                    + "<h4> <br/><a href=" + url + ">" + "click here" + "</a> <br/></h4>"
                    + "<h4> If you did not request a password reset, please ignore this email or reply to let us know.<br/><br/> Thank you.</h4>"
                    + "</div>";

                // Send mail to client
                try
                {
                    EmailManager emailManager = new EmailManager();
                    emailManager.SendEmail(emailModel);
                }
                catch (Exception ex)
                {
                    GlobalVariable.log.Write(LogLevel.Error, ex);
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                GlobalVariable.log.Write(LogLevel.Error, ex);
                throw ex;
            }
        }
        public string SendMail(EmailModel userDetails)
        {
            string result = string.Empty;

            try
            {
                string     smtpHost   = System.Configuration.ConfigurationManager.AppSettings["smtpHost"];
                string     smtpPort   = System.Configuration.ConfigurationManager.AppSettings["smtpPort"];
                SmtpClient smtpClient = new SmtpClient(smtpHost, Convert.ToInt32(smtpPort));

                string smtpFromMailId   = System.Configuration.ConfigurationManager.AppSettings["smtpFromMailId"];
                string smtpFromPassword = System.Configuration.ConfigurationManager.AppSettings["smtpFromPassword"];

                smtpClient.Credentials    = new System.Net.NetworkCredential(smtpFromMailId, smtpFromPassword);
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.EnableSsl      = true;
                MailMessage mail = new MailMessage();

                //Setting From , To and CC
                string smtpFromDisplayName = System.Configuration.ConfigurationManager.AppSettings["smtpFromDisplayName"];
                string smtpToMailId        = System.Configuration.ConfigurationManager.AppSettings["smtpToMailId"];
                mail.From = new MailAddress(smtpFromMailId, smtpFromDisplayName);
                mail.To.Add(new MailAddress(smtpToMailId));
                mail.Subject    = userDetails.UserSubject;
                mail.Body       = string.Format(GetMailTemplate(), userDetails.UserName, userDetails.UserMailId, userDetails.UserPhoneNo, userDetails.UserSubject, userDetails.UserMessage);
                mail.IsBodyHtml = true;
                smtpClient.Send(mail);
                result = "success";
            }
            catch (Exception exception)
            {
                var ex = exception.Message;
                result = "failed";
            }
            return(result);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Creates email model instance using <paramref name="emailDto"/>.
        /// </summary>
        /// <param name="emailDto"><see cref="Email"/> instance.</param>
        /// <returns>Email model instnace.</returns>
        private EmailModel CreateEmailModel(Email emailDto)
        {
            var utils      = ClassFactory.Get <IActivityUtils>();
            var emailModel = new EmailModel()
            {
                From       = emailDto.Sender,
                Subject    = utils.FixActivityTitle(emailDto.Subject, _userConnection),
                SendDate   = utils.GetSendDateFromTicks(_userConnection, emailDto.SendDateTimeStamp),
                IsHtmlBody = emailDto.IsHtmlBody,
                Headers    = emailDto.Headers,
                To         = emailDto.Recepients,
                Copy       = emailDto.CopyRecepients,
                BlindCopy  = emailDto.BlindCopyRecepients,
                Importance = emailDto.Importance,
                MessageId  = emailDto.MessageId,
                InReplyTo  = emailDto.InReplyTo,
                References = emailDto.References
            };

            emailModel.Attachments  = CreateAttachments(emailDto, out string fixedBody);
            emailModel.Body         = fixedBody;
            emailModel.OriginalBody = emailDto.Body;
            return(emailModel);
        }
Exemplo n.º 16
0
        public void SendEmail(EmailModel emailModel)
        {
            try
            {
                using (SmtpClient client = new SmtpClient(_host))
                {
                    MailMessage mailMessage = new MailMessage();
                    mailMessage.From = new MailAddress(_from, _alias);

                    mailMessage.BodyEncoding = Encoding.UTF8;

                    mailMessage.To.Add(emailModel.To);
                    mailMessage.Body       = emailModel.Message;
                    mailMessage.Subject    = emailModel.Subject;
                    mailMessage.IsBodyHtml = emailModel.IsBodyHtml;

                    client.Send(mailMessage);
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 17
0
        public bool UpdateRequisitionCollectionTime(Requisition r1)
        {
            try
            {
                Requisition original = rrepo.UpdateRequisitionCollectionTime(r1);
                Employee    drep     = erepo.FindEmpById((int)original.Department.RepId);
                Employee    deptemp  = erepo.FindEmpById(original.ReqByEmpId);
                EmailModel  email    = new EmailModel();

                Task.Run(async() =>
                {
                    EmailTemplates.CollectionTimeTemplate ctt = new EmailTemplates.CollectionTimeTemplate(original, drep);
                    email.emailTo      = drep.Email;
                    email.emailSubject = ctt.subject;
                    email.emailBody    = ctt.body;
                    await mailservice.SendEmailwithccAsync(email, deptemp);
                });
                return(true);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 18
0
        public JsonResponse <int> SendCorporateTieUpEmail(CorporateTieUpEnquiry model)
        {
            JsonResponse <int> response = new JsonResponse <int>();

            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <CorporateTieUpEnquiry, EmailModel>();
            });

            IMapper    iMapper = config.CreateMapper();
            EmailModel email   = iMapper.Map <CorporateTieUpEnquiry, EmailModel>(model);

            string otherContent = "Company: " + model.CompanyName;

            email.Subject = "Enquiry for Corporate Tie Up.";
            int status = EmailHelper.PrepareAndSendEmail(email, otherContent);

            if (status == (int)AspectEnums.EmailStatus.Sent)
            {
                log.Info(string.Format("Email successfully sent to {0} at {1}.", model.Name, model.Email));
                response.Message      = string.Format("Email successfully sent to {0} at {1}.", model.Name, model.Email);
                response.StatusCode   = "200";
                response.IsSuccess    = true;
                response.SingleResult = status;
            }
            else
            {
                log.Info(string.Format("Could not send email to {0} at {1}.", model.Name, model.Email));
                response.Message      = string.Format("Could not send email to {0} at {1}.", model.Name, model.Email);
                response.StatusCode   = "500";
                response.IsSuccess    = false;
                response.SingleResult = status;
            }

            return(response);
        }
        public bool SendEmail(EmailModel modal)
        {
            try
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
                mail.IsBodyHtml = true;
                mail.From       = new MailAddress(modal.FromAddress);
                mail.To.Add(modal.ToAddress);
                mail.Subject           = modal.Subject;
                mail.Body              = modal.Body;
                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Testingmr@7");
                SmtpServer.EnableSsl   = true;
                SmtpServer.Send(mail);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
Exemplo n.º 20
0
        public async Task <ActionResult> Contact(EmailModel model)

        {
            if (ModelState.IsValid)
            {
                try
                {
                    //var body = model.Body;
                    var from = $"{model.FromEmail}<{WebConfigurationManager.AppSettings["emailto"]}>";

                    // model.Body = "This is a message from your portfolio site.  The name and the email of the contacting person is above.";

                    var email = new MailMessage(from,
                                                WebConfigurationManager.AppSettings["emailto"])

                    {
                        Subject = model.Subject,
                        Body    = $"You have an email from{model.FromName}<br/>{model.Body}",
                        //string.Format(body, model.FromName, model.FromEmail, model.Body),
                        IsBodyHtml = true
                    };

                    var svc = new PersonalEmail();
                    await svc.SendAsync(email);

                    return(View(new EmailModel()));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    await Task.FromResult(0);
                }
            }

            return(View(model));
        }
        public void ProcessEmail(EmailModel emailModel)
        {
            try
            {
                var mailMessage = new MailMessage
                {
                    Body       = emailModel.Body,
                    From       = new MailAddress(emailModel.SenderEmail, emailModel.SenderDisplayName),
                    Subject    = emailModel.Subject,
                    IsBodyHtml = emailModel.IsHtmlContent,
                    Priority   = MailPriority.High
                };

                //mailMessage.ReplyToList.Add("");
                ProcessReceivers(emailModel, mailMessage);
                ProcessAttachments(emailModel, mailMessage);

                SendMail(mailMessage);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 22
0
        public virtual MvcMailMessage EmailOrText(EmailModel model, string MailType = "Email")
        {
            ViewBag.Title = string.Format("Message from {0}", model.MinistryName);
            if (MailType == "Email")
            {
                ViewBag.Message = model.EmailMessage;
            }
            else
            {
                ViewBag.Message = model.TextMessage;
            }
            ViewBag.SenderCode = model.SenderCode;

            return(Populate(x =>
            {
                foreach (var file in model.files)
                {
                    if (file != null && file.ContentLength > 0)
                    {
                        x.Attachments.Add(new Attachment(file.InputStream, Path.GetFileName(file.FileName)));
                    }
                }
                x.Subject = model.Subject;
                x.ViewName = "EmailOrText";
                x.From = new System.Net.Mail.MailAddress(model.FromEmail);
                x.To.Add(new System.Net.Mail.MailAddress(model.FromEmail));
                x.IsBodyHtml = true;
                foreach (string e in model.EmailString)
                {
                    if (e != null)
                    {
                        x.Bcc.Add(e);
                    }
                }
            }));
        }
Exemplo n.º 23
0
        public IActionResult Email(EmailModel email)
        {
            string messageBody = "";

            if (ModelState.IsValid)
            {
                //var builder = new BodyBuilder
                //{
                //    HtmlBody = email.HtmlData
                //};

                //messageBody = string.Format(builder.HtmlBody,
                //String.Format("{0:dddd, d MMMM yyyy}", DateTime.Now),
                //"*****@*****.**",
                //"Nazmul",
                //"123456");
            }
            var model = new EmailModel
            {
                HtmlData = messageBody
            };

            return(View(model));
        }
Exemplo n.º 24
0
        public ActionResult SeeHtml(int id)
        {
            var m = new EmailModel(id);

            if (m.queue == null)
            {
                return(Content("no email found"));
            }
            var curruser = DbUtil.Db.LoadPersonById(Util.UserPeopleId ?? 0);

            if (curruser == null)
            {
                return(Content("no user"));
            }
            if (User.IsInRole("Admin") ||
                User.IsInRole("ManageEmails") ||
                m.queue.FromAddr == curruser.EmailAddress ||
                m.queue.QueuedBy == curruser.PeopleId ||
                m.queue.EmailQueueTos.Any(et => et.PeopleId == curruser.PeopleId))
            {
                return(View(m));
            }
            return(Content("not authorized"));
        }
        public async Task <bool> SendHelpEmail(string subject, string message)
        {
            bool IsSuccessful = false;

            if (subject == null || message == null)
            {
                return(IsSuccessful);
            }

            EmailModel emailModel = new EmailModel();

            emailModel.Sender        = _configuration["Sender"];
            emailModel.Recipient     = _configuration["Sender"];
            emailModel.TrackOpens    = true;
            emailModel.Subject       = "[" + _configuration["Sender"] + "]: " + subject;
            emailModel.TextBody      = message;
            emailModel.HtmlBody      = message;
            emailModel.MessageStream = _configuration["MessageStream"];
            emailModel.Tag           = helpTag;

            IsSuccessful = await _emailService.SendEmail(emailModel);

            return(IsSuccessful);
        }
Exemplo n.º 26
0
        public EmailModel ToEmailModel()
        {
            var ToReturn = new EmailModel();

            ToReturn.Name          = this.FullName;
            ToReturn.Address1      = this.Address1;
            ToReturn.Address2      = this.Address2;
            ToReturn.BadgeName     = this.BadgeName;
            ToReturn.City          = this.City;
            ToReturn.Country       = this.Country;
            ToReturn.Email         = this.Email;
            ToReturn.NumCritiques  = this.Critiques == null ? "0" : this.Critiques.Count().ToString();
            ToReturn.Phone         = this.Phone;
            ToReturn.PostalCode    = this.PostalCode;
            ToReturn.SpecialNeeds  = this.SpecialNeeds;
            ToReturn.State         = this.State;
            ToReturn.Type          = this.Registration.Type;
            ToReturn.Track         = this.Registration.Track;
            ToReturn.Intensive     = this.Registration.Intensive;
            ToReturn.FridayLunch   = this.Registration.FridayLunch;
            ToReturn.SaturdayLunch = this.Registration.SaturdayLunch;

            return(ToReturn);
        }
Exemplo n.º 27
0
        public static void SendInvoiceEmail(EmailModel invoiceToSend)
        {
            SmtpClient SmtpServer = EmailHelper.SetSmtp();
            String     Username   = System.Configuration.ConfigurationManager.AppSettings["emailUsername"];

            MailAddress from    = new MailAddress(Username);
            string      subject = "Invoice: ";

            MailMessage mail = new MailMessage();

            mail.IsBodyHtml = true;
            mail.From       = from;
            mail.Subject    = subject;

            double subtotal = 0;
            double taxRate  = 0.17;
            double tax      = 0;
            double total    = 0;
            string bodyHtml = "";

            bodyHtml = "<h2 style='font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;'>INVOICE #" + invoiceToSend.Id + " " + invoiceToSend.Status + "</h2><h1 style='font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;'>XYZ<br/><small>Makes billing easy</small></h1><hr><h4>Date:" + invoiceToSend.Date + "</h4><h5>Invoice ID:" + invoiceToSend.Id + "</h5><h5>Customer ID:" + invoiceToSend.Customer + "</h5><hr><div style='width:20vw; display:inline-block; border: #008cba solid;margin:10px; padding:5px':> <strong>From:</strong></h3> <div class='panel-body'> <p>2854 Granville Lane</p><p>Newark, 07104</p><p>973-482-1872</p><p> </p><p> </p><p> </p><p> </p></div></div><div style='width:20vw; display:inline-block; border: #008cba solid;margin:10px; padding:5px':> <strong>Bill To:</strong></h3> <div class='panel-body'> <p>Customer Name" + invoiceToSend.BillTo.Name + "</p><p>Company Name:" + invoiceToSend.BillTo.CompanyName + "</p><p>Street Address:" + invoiceToSend.BillTo.StreetAddress + "</p><p>City, Zip:" + invoiceToSend.BillTo.City + ", " + invoiceToSend.BillTo.ZipCode + "</p><p>Phone/Fax:" + invoiceToSend.BillTo.PhoneNumber + "</p></div></div><div style='width:20vw; display:inline-block; border: #008cba solid;margin:10px; padding:5px':> <strong>Ship To:</strong> <div class='panel-body'> <p>Customer Name:" + invoiceToSend.ShipTo.Name + "</p><p>Company Name:" + invoiceToSend.ShipTo.CompanyName + "</p><p>Street Address:" + invoiceToSend.ShipTo.StreetAddress + "</p><p>City, Zip:" + invoiceToSend.ShipTo.City + "," + invoiceToSend.ShipTo.ZipCode + "</p><p>Phone/Fax:" + invoiceToSend.ShipTo.PhoneNumber + "</p></div></div><div> <div style='width:13vw; display:inline-block;'><h4>ID</h4></div><div style='width:13vw; display:inline-block;'><h4>Description</h4></div><div style='width:13vw; display:inline-block;'><h4>Amount</h4></div><div style='width:13vw; display:inline-block;'><h4>Quantity</h4></div><div style='width:13vw; display:inline-block;'><h4>Total</h4></div></div><hr>";
            foreach (InvoiceItemModel i in invoiceToSend.Items)
            {
                bodyHtml += "<div style='width:13vw; display:inline-block;'>" + i.Id + "</div><div style='width:13vw; display:inline-block;'>" + i.Description + "</div><div style='width:13vw; display:inline-block;'>" + i.Price + "</div><div style='width:13vw; display:inline-block;'>" + i.Quantity + "</div><div style='width:13vw; display:inline-block;'>" + i.Quantity * i.Price + "</div>";
                subtotal += i.Quantity * i.Price;
            }
            tax   = subtotal * taxRate;
            total = subtotal + tax;

            bodyHtml += "<hr><hr><div><p><strong>Subtotal:" + Math.Round(subtotal, 2) + "</strong></p><p><strong>Tax Rate:" + Math.Round(taxRate, 2) + "</strong></p><p><strong>Tax:" + tax + "</strong></p><p><strong>Other: </strong></p><h3><strong>TOTAL:" + Math.Round(total, 2) + "</strong></h3></div>";


            mail.Body = bodyHtml;
            mail.To.Add(new MailAddress(invoiceToSend.MailTo));
            SmtpServer.Send(mail);
        }
    protected void submit_Click(object sender, EventArgs e)
    {
        var name = nameTextbox.Text;
        var email = emailTextBox.Text;
        var mobile = mobileTextbox.Text;
        var message = messageTextBox.Text;
        var service = dropdownService.SelectedValue;
        EmailModel emailModel = new EmailModel(email, mobile, name, message, service);
        SupportModel supportModel = new SupportModel();
        var emailSentSuccessfully = supportModel.sendMail(emailModel);

        if (emailSentSuccessfully)
        {
            emailTextBox.Visible = false;
            mobileTextbox.Visible = false;
            nameTextbox.Visible = false;
            messageTextBox.Visible = false;
            terms_checkbox.Visible = false;
            downloadLink.Visible = true;
            termsAndCondition.Visible = false;
            submitBtn.Visible = false;
            configText.Visible = false;
            downloadLabel.Visible = true;
            emailTitle.Visible = false;
            nameTitle.Visible = false;
            phoneNumberTitle.Visible = false;
            messageTitle.Visible = false;
            serviceLabel.Visible = false;
            dropdownService.Visible = false;
            CheckBoxRequired.Visible = false;
            MainHeader.Text = "Your request has been sent in! Sit back and relax! A representative will get in contact with you shortly, Expect a call to this number: " + mobileTextbox.Text;
            downloadLabel.Text = "Our agents to assist you soon. A link will be provided to allow agent to assist you once you receive a call \r\n.";

        }
        
    }
Exemplo n.º 29
0
        public ActionResult Email(EmailModel model)
        {
            if (ModelState.IsValid)
            {
                EmailConfigInfo emailConfigInfo = BSPConfig.EmailConfig;

                emailConfigInfo.Host         = model.Host;
                emailConfigInfo.Port         = model.Port;
                emailConfigInfo.From         = model.From;
                emailConfigInfo.FromName     = model.FromName;
                emailConfigInfo.UserName     = model.UserName;
                emailConfigInfo.Password     = model.Password;
                emailConfigInfo.FindPwdBody  = model.FindPwdBody;
                emailConfigInfo.SCVerifyBody = model.SCVerifyBody;
                emailConfigInfo.SCUpdateBody = model.SCUpdateBody;
                emailConfigInfo.WebcomeBody  = model.WebcomeBody;

                BSPConfig.SaveEmailConfig(emailConfigInfo);
                Emails.ResetEmail();
                AddAdminOperateLog("修改邮箱设置");
                return(PromptView(Url.Action("email"), "修改邮箱设置成功"));
            }
            return(View(model));
        }
Exemplo n.º 30
0
        /// <summary>
        ///   will  use  in  back end  when  you  invest  api  for example  forget  password  it  will  call this  method
        /// </summary>
        /// <param name="emailModel"></param>
        /// <returns></returns>
        public static bool SendEmail(EmailModel emailModel)
        {
            bool isSent = true;

            try
            {
                var fromAddress = new MailAddress(AppSession.CompanyEmail, string.IsNullOrEmpty(emailModel.FromName) ?
                                                  AppSession.CompanyEmailDisplayName : emailModel.FromName);
                MailMessage mail = new MailMessage();
                mail.From = fromAddress;
                mail.To.Add(new MailAddress(emailModel.To));
                if (!string.IsNullOrEmpty(emailModel.CC))
                {
                    mail.CC.Add(new MailAddress(emailModel.CC));
                }

                mail.Subject    = emailModel.Subject;
                mail.Body       = emailModel.Body;
                mail.IsBodyHtml = true;
                mail.Priority   = MailPriority.High;

                using (SmtpClient smtp = new SmtpClient())
                {
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    smtp.Credentials = new NetworkCredential(fromAddress.Address, AppSession.CompanyEmailPassword);
                    smtp.Send(mail);
                }
            }
            catch (Exception ex)
            {
                var exception = $" Oops! Message could not be sent. Error:  {ex.Message}";
            }
            return(isSent);
        }
Exemplo n.º 31
0
        public async Task <JsonResult> SendGridMail(string YourEmail, string Subject)
        {
            EmailModel emailModel = new EmailModel();

            emailModel.From = "*****@*****.**";
            emailModel.Tos.Add(YourEmail);
            emailModel.PlainTextContent = "Hello, SendGrid Email!";
            emailModel.Subject          = Subject;
            emailModel.HtmlContent      = "<strong>Hello, Email!, Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";

            var customerData = JsonConvert.SerializeObject(emailModel);
            var buffer       = System.Text.Encoding.UTF8.GetBytes(customerData);
            var byteData     = new ByteArrayContent(buffer);

            byteData.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(URL); //http://localhost:7071/api/
            var response = await client.PostAsync("SendMail", byteData);

            client.Dispose();


            //var client = new SendGridClient("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");
            //var msg = new SendGridMessage()
            //{
            //    From = new EmailAddress("*****@*****.**", "DX Team"),
            //    Subject = "Hello World from the SendGrid CSharp SDK!",
            //    PlainTextContent = "Hello, Email!",
            //    HtmlContent = "<strong>Hello, Email!</strong>"
            //};
            //msg.AddTo(new EmailAddress("*****@*****.**", "Test User"));
            //var response = await client.SendEmailAsync(msg);

            return(Json("", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 32
0
        }         // ProcessRequest

        private EmailModel PrepareEmail(string templateName, string to, Dictionary <string, string> variables, string subject, string cc = "", List <attachment> attachments = null)
        {
            var toList = PrepareRecipients(to);

            var message = new EmailModel {
                key           = MandrillKey,
                template_name = templateName,
                message       = new EmailMessageModel {
                    to           = toList,
                    subject      = subject,
                    bcc_address  = cc,
                    attachments  = attachments,
                    track_clicks = true,
                    track_opens  = true,
                },
            };

            foreach (var var in variables)
            {
                message.AddGlobalVariable(var.Key, var.Value);
            }

            return(message);
        }         // PrepareEmail
        public async Task <ActionResult> SendEmail(EmailModel email)
        {
            try
            {
                //1. Envio de Correo con Sendgrid
                EmailHelper    emailHelper = new EmailHelper();
                ResponseHelper response    = await emailHelper.SendGeneralEmail(email.Email, email.Subject, email.Body);

                if (response.Result)
                {
                    //2. Almacenar datos del correo
                    Mail mail = new Mail();
                    mail.ToEmail  = email.Email;
                    mail.Subject  = email.Subject;
                    mail.Body     = email.Body;
                    mail.SendDate = DateTime.Now;
                    mail.Status   = 1;

                    RepositoryHelper repository = new RepositoryHelper();
                    repository.SaveEmail(mail);
                    return(Json(response));
                }
                else
                {
                    return(Json(response));
                }
            } catch (Exception ex)
            {
                return(Json(new ResponseHelper
                {
                    Result = false,
                    Status = 500,
                    Message = ex.InnerException.Message
                }));
            }
        }
Exemplo n.º 34
0
        public async Task <ActionResult> Contact(EmailModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var body = "<p>Email From: <bold>{0}</bold>" +
                               "({1})</p><p>Message:</p><p>{2}</p>";
                    model.Body = "This is a message from your bug tracker site. The name and" +
                                 "the email of the contacting person is above.";

                    var svc = new EmailService();
                    var msg = new IdentityMessage()
                    {
                        Subject     = "Contact from bug tracker site",
                        Body        = string.Format(body, model.FromName, model.FromEmail, model.Body),
                        Destination = "*****@*****.**"
                    };

                    await svc.SendAsync(msg);

                    return(View());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    await Task.FromResult(0);

                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }
Exemplo n.º 35
0
        private async Task DisplayEmailContent()
        {
            EmailModel        model     = null;
            List <EmailModel> allEmails = _emailManager.GetAllDownloadedEmails();

            if (allEmails != null && SelectedEmail != null)
            {
                model = allEmails.FirstOrDefault(x => x.Id == SelectedEmail.Id);
            }

            if (model != null)
            {
                if (model.Body != null)
                {
                    BodyHtml = model.Body.Html;
                }
                else
                {
                    var body = await _emailManager.DownloadEmailBody(SelectedEmail.Id);

                    BodyHtml = body;
                }
            }
        }
Exemplo n.º 36
0
        private bool EnviarNotificacionAlPaciente(int idTurno)
        {
            var turnoDB       = db.Turno.Include(t => t.Especialidad).Include(t => t.Factura).Include(t => t.FormaDePago).Include(t => t.Medico).Include(t => t.Paciente).Include(t => t.SegurosMedico).Include(t => t.ServicioExtra).First(x => x.IdTurno == idTurno);
            var pacienteEmail = turnoDB.Paciente.Email;
            var emailSubject  = string.Format("Nuevo Turno para el {0} a las {1} hs.", turnoDB.FechaYHora.ToString("dd/MM/yyyy"), turnoDB.FechaYHora.ToString("HH:mm"));
            var emailBody     = string.Format(_bodyTemplate,
                                              turnoDB.FechaYHora.ToString("dd/MM/yyyy HH:mm"),
                                              turnoDB.Paciente.Apellidos + ", " + turnoDB.Paciente.Nombres,
                                              turnoDB.Medico.PersonalInterno.Single().Apellido + ", " + turnoDB.Medico.PersonalInterno.Single().Nombre,
                                              turnoDB.Especialidad.Nombre,
                                              turnoDB.Medico.MatriculaMedico,
                                              turnoDB.FormaDePago == null ? "" : turnoDB.FormaDePago.Nombre,
                                              turnoDB.PrecioTurno,
                                              turnoDB.SegurosMedico == null ? "" : turnoDB.SegurosMedico.Nombre,
                                              turnoDB.Descripcion,
                                              turnoDB.Diagnostico,
                                              turnoDB.ServicioExtra == null ? "" : turnoDB.ServicioExtra.Nombre,
                                              turnoDB.Descripcion ?? "");
            var emailModel = new EmailModel {
                ToEmail = pacienteEmail, EmailSubject = emailSubject, EMailBody = emailBody
            };

            return(EnviarEmail(emailModel));
        }
Exemplo n.º 37
0
        public EmailModel PostDeleteEmailWithEmailTVItemIDDB(int EmailTVItemID)
        {
            ContactOK contactOK = IsContactOK();

            if (!string.IsNullOrEmpty(contactOK.Error))
            {
                return(ReturnError(contactOK.Error));
            }

            EmailModel EmailModelToDelete = GetEmailModelWithEmailTVItemIDDB(EmailTVItemID);

            if (!string.IsNullOrWhiteSpace(EmailModelToDelete.Error))
            {
                return(ReturnError(EmailModelToDelete.Error));
            }

            EmailModelToDelete = PostDeleteEmailDB(EmailModelToDelete.EmailID);
            if (!string.IsNullOrWhiteSpace(EmailModelToDelete.Error))
            {
                return(ReturnError(EmailModelToDelete.Error));
            }

            return(ReturnError(""));
        }
Exemplo n.º 38
0
        public async Task <ActionResult> Contact(EmailModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var message = "<p>Email From: <bold>{0}</bold>({1})</p><p> Message:</p><p>{2}</p> ";
                    //var from = "MyPortfolio<*****@*****.**>";
                    //model.Body = "This is a message from your portfolio site.  The name and the email of the contacting person is above.";

                    var testVar = ConfigurationManager.AppSettings["emailto"];

                    var email = new MailMessage(model.FromEmail, ConfigurationManager.AppSettings["emailto"])
                    {
                        Subject    = model.Subject,
                        Body       = string.Format(message, model.FromName, model.FromEmail, model.Body),
                        IsBodyHtml = true
                    };

                    var svc = new PersonalEmail();
                    await svc.SendAsync(email);

                    ModelState.Clear();

                    TempData["status"] = "success";
                    return(View(new EmailModel()));
                }
                catch (Exception ex)
                {
                    TempData["status"] = "error";
                    Console.WriteLine(ex.Message);
                    await Task.FromResult(0);
                }
            }
            return(View(model));
        }
Exemplo n.º 39
0
        public ActionResult Register(RegisterModel model)  // регистрация
        {
	// Всякие проверки
            if (model.ConfirmPassword == null || model.EmailAdres == null || model.Password == null || model.UserName == null)
            {
                ModelState.AddModelError("MyError", "Ошибка! Заполните все поля!");
                return View(model);
            }
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    if (model.EmailAdres.IndexOf('@') < 1)
                    {
                        ModelState.AddModelError("EmailAdres", "E-mail адрес введен не корректно");
                        return View(model);
                    }
                    List<int> qwe = new List<int>();
                    for (int i = 0; i < model.UserName.Length; i++)
                    {
                        qwe.Add((char)model.UserName[i]);
                    }
                    bool LoginValid = false;
                    for (int i = 0; i < model.UserName.Length; i++)
                    {
                        if (((int)model.UserName[i] > 47 && (int)model.UserName[i] < 58) ||
                            ((int)model.UserName[i] > 64 && (int)model.UserName[i] < 91) ||
                            ((int)model.UserName[i] > 96 && (int)model.UserName[i] < 123))
                            LoginValid = true;
                        else
                        {
                            ModelState.AddModelError("UserName", "Имя пользователя должно состоять из следущих символо: A-Z и 0-9");
                            return View(model);
                        }
                    }
                    if (LoginValid) 
                    {
                        model.UserName.ToLower();
                        model.EmailAdres.ToLower();
                        if (WebSecurity.UserExists(model.UserName))
                        {
                            ModelState.AddModelError("UserName", "Логин занят");
                            return View(model);
                        }
                        UsersContext db = new UsersContext();
                        List<EmailModel> emailCheck = new List<EmailModel>();
                        emailCheck = db.EmailModels.ToList();
                        for (int i = 0; i < emailCheck.Count; i++)
                        {
                            if (emailCheck[i].Email == model.EmailAdres)
                            {
                                ModelState.AddModelError("UserName", "Пользователь с таким e-mail уже существует");
                                return View(model);
                            }
                        }
			// ТУТ СОЗДАЕМ НОВОГО ПОЛЬЗОВАТЕЛЯ
                        WebSecurity.CreateUserAndAccount(model.UserName, model.Password);

			// сРАЗУЖЕ ЛОГИНИМСЯ

                        bool logged = WebSecurity.Login(model.UserName, model.Password);

                        if (logged)
                        {
                            //set auth cookie
                            FormsAuthentication.SetAuthCookie(model.UserName, false);
                        }
                        
                        UserProfile TempProfile = db.UserProfiles.Find(WebSecurity.GetUserId(model.UserName));
                        UserData CurrentUserDataModel = new UserData(TempProfile);
                        db.UsersData.Add(CurrentUserDataModel);
                        db.SaveChanges();

			// ГЕНЕРИРУЕМ КОТД ПОДТВЕРЖДЕНИЯ
                        EmailModel e = new EmailModel();
                        e.Email = model.EmailAdres;
                        e.IsConfirm = false;
                        e.Key = Crypto.SHA256(model.EmailAdres);
                        e.PasswordRecoverKey = Crypto.SHA256(model.EmailAdres + model.Password + model.UserName);
                        e.UserProfile = TempProfile;
                        db.EmailModels.Add(e);
                        db.SaveChanges();

                        SendMail("smtp.mail.ru", "ЯЩИК С КОТОРОГО ОТПРАВЛЯЕТЯ ПИСЬМО", "ПАРОЛЬ ОТ ЯЩИКА", e.Email , "public", "Welcom to public " +
                            "Пожалуйста, активируйте Ваш аккаунт, перейдя по этой ссылке http://public.somee.com/Account/ActivationAccount/" + e.Key, null);
                        ViewBag.currentUser = CurrentUserDataModel;
                        return View("AddData", CurrentUserDataModel);
                    }
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }
            else
            {
                for (int i = 0; i < model.UserName.Length; i++)
                {
                    if ((int)model.UserName[i] < 48 || (int)model.UserName[i] > 57 || (int)model.UserName[i] < 65 || (int)model.UserName[i] > 90 || (int)model.UserName[i] < 97 || (int)model.UserName[i] > 122 )
                        ModelState.AddModelError("UserName", "Имя пользователя должно состоять из следущих символо: A-Z и 0-9");
                }
                if (model.UserName.Length < 4)
                    ModelState.AddModelError("UserName", "Имя пользователя должно быть не менее трех символов");
                if (model.Password != model.ConfirmPassword)
                    ModelState.AddModelError("ConfirmPassword", "Оба пароля должны быть идентичны");
                if (model.EmailAdres.IndexOf('@') < 1)
                    ModelState.AddModelError("EmailAdres", "E-mail адрес введен не корректно");
                
            }
            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public void SendEmail(EmailModel model)
 {
     _emailGatewayClient.SendSimpleEmail(model);
 }
Exemplo n.º 41
0
	// АКТИВАЦИЯ АККАУНТА ЕСЛИ ПОЛЬЗОВАТЕЛЬ ПЕРЕШЕЛ ПО ССЫЛКЕ
        public ActionResult ActivationAccount(string ActivatonCode)
        {
            UsersContext db = new UsersContext();
            EmailModel userEmail = new EmailModel();
            List<EmailModel> TempList = new List<EmailModel>();
            TempList = db.EmailModels.ToList();
            for (int i = 0; i < TempList.Count; i++)
            {
                if (ActivatonCode == TempList[i].Key && WebSecurity.CurrentUserId == TempList[i].UserProfile.UserId)
                {
                    userEmail = TempList[i];
                    var EditUser = db.EmailModels
                    .Where(c => c.Id == userEmail.Id)
                    .FirstOrDefault();
                    EditUser.IsConfirm = true;
                    db.SaveChanges();
                    break;
                }
            }
            ViewBag.EmailError = null;
            return RedirectToAction("Index", "Home");
        }
Exemplo n.º 42
0
 public void SendEmail(EmailModel Model)
 {
     ((IEmailSender)BusinessLogicFactory.BusinessLogicFactory.CreateBusinessObject<IEmailSender>()).SendEmail(Model);
 }
Exemplo n.º 43
0
        public ActionResult TestServiceUp()
        {
            EmailModel model = new EmailModel { FromEmailAddress = "*****@*****.**", ToEmailAddress = "*****@*****.**", Body = "Body", Subject = "Subject" };

            return Json(model, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 44
0
        public ActionResult Email(EmailModel model)
        {
            if (ModelState.IsValid)
            {
                EmailConfigInfo emailConfigInfo = BSPConfig.EmailConfig;

                emailConfigInfo.Host = model.Host;
                emailConfigInfo.Port = model.Port;
                emailConfigInfo.From = model.From;
                emailConfigInfo.FromName = model.FromName;
                emailConfigInfo.UserName = model.UserName;
                emailConfigInfo.Password = model.Password;
                emailConfigInfo.FindPwdBody = model.FindPwdBody;
                emailConfigInfo.SCVerifyBody = model.SCVerifyBody;
                emailConfigInfo.SCUpdateBody = model.SCUpdateBody;
                emailConfigInfo.WebcomeBody = model.WebcomeBody;

                BSPConfig.SaveEmailConfig(emailConfigInfo);
                Emails.ResetEmail();
                AddAdminOperateLog("修改邮箱设置");
                return PromptView(Url.Action("email"), "修改邮箱设置成功");
            }
            return View(model);
        }
Exemplo n.º 45
0
        public ActionResult Email()
        {
            EmailConfigInfo emailConfigInfo = BSPConfig.EmailConfig;

            EmailModel model = new EmailModel();
            model.Host = emailConfigInfo.Host;
            model.Port = emailConfigInfo.Port;
            model.From = emailConfigInfo.From;
            model.FromName = emailConfigInfo.FromName;
            model.UserName = emailConfigInfo.UserName;
            model.Password = emailConfigInfo.Password;
            model.FindPwdBody = emailConfigInfo.FindPwdBody;
            model.SCVerifyBody = emailConfigInfo.SCVerifyBody;
            model.SCUpdateBody = emailConfigInfo.SCUpdateBody;
            model.WebcomeBody = emailConfigInfo.WebcomeBody;

            return View(model);
        }
Exemplo n.º 46
0
        public ActionResult RecoverPassword(PasswordRecoverModel Model)
        {
            if (Model.Email == null || Model.Name == null)
            {
                ModelState.AddModelError("MyObject", "Заполните все поля");
                    return View();
            }
            UsersContext db = new UsersContext();
            EmailModel FindUser = new EmailModel();
            List<EmailModel> _tempList = new List<EmailModel>();
            _tempList = db.EmailModels.ToList();
            for (int i = 0; i <_tempList.Count; i++)
			 if (_tempList[i].Email.Trim().ToLower() == Model.Email.Trim().ToLower() &&
                 _tempList[i].UserProfile.UserName.Trim().ToLower() == Model.Name.Trim().ToLower())
             {
                 FindUser = _tempList[i];
                 break;
             }
        if (FindUser.Email == null)
        {
            ModelState.AddModelError("MyObject", "Данные введены не корректно");
            return View();
        }

            string Key = WebSecurity.GeneratePasswordResetToken(FindUser.UserProfile.UserName);
            SendMail("smtp.mail.ru", "*****@*****.**", "7632bxr29zx6", FindUser.Email, "public", "Welcom to public " +
                           "Для восстановления пароля перейдите по этой ссылке http://public.somee.com/Account/RecoverPasswordPage?Key=" + Key, null);
                        
            return View();
        }