Exemplo n.º 1
0
        protected void SendLoginMail(string sendaddress)

        {
            try
            {
                string actcode = strMerchant.ToString() + Guid.NewGuid().ToString().Replace("-", string.Empty);

                string activationCode = Encodings.EncodeTo64(string.Format("{0};{1};{2}",
                                                                           actcode, txtemail.Value.ToString(), strMerchant.ToString()));

                string url = string.Format("http://{0}{1}", Request.Url.Authority,
                                           ResolveUrl("ActivationEmail.aspx"));
                string urls = string.Format("{0}{1}", url, string.Format("?verify={0}", activationCode)); Console.WriteLine(url);

                string smtpAddress = ConfigurationManager.AppSettings["SMTPHost"];
                int    portNumber  = int.Parse(ConfigurationManager.AppSettings["SMTPPort"]);
                bool   enableSSL   = true;


                string emailFrom = ConfigurationManager.AppSettings["SMTPAddress"];
                string password  = ConfigurationManager.AppSettings["SMTPPassword"];
                string emailTo   = sendaddress;
                string subject   = ConfigurationManager.AppSettings["EmailSubject"];
                string body      = "Dear <p></p><br/> " + sendaddress + ",<p></p><br/> <br/>Your account password reset request received sucessfully. <p>Click here, if you made a request</p><br/><br><a href=" + urls + ">  Reset Password </a> <br/>  <p>or ingore the request.</p><br/> Thanks you<br/><p></p><p></p>Regards,<p></p><p></p><br/><br/>Mail  Team";

                //< strong style = "text-decoration: none; font-size: 22px; font-weight: bold; color: #fff; outline: none" >< span style = "padding-bottom: 20px; padding-top: 20px; padding-left: 40px; padding-right: 40px; display: inline-block; background-color: #1d9092; border-radius: 50px" > Confirm Email </ span ></ strong >

                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress(emailFrom);
                    if (IsValidEmail(sendaddress.ToString()))
                    {
                        mail.To.Add(sendaddress);
                    }

                    mail.Subject    = "Account Notification";
                    mail.Body       = body;
                    mail.IsBodyHtml = true;

                    //SaveMail();

                    using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                    {
                        smtp.Credentials = new NetworkCredential(emailFrom, password);
                        smtp.EnableSsl   = enableSSL;
                        smtp.Send(mail);
                        //sent = true;
                    }
                }
            }
            catch (Exception ex)
            {
                //logger.Error(ex.Message, "Error occured!");
                //lblerror.Text = ex.Message.ToString();
                //lblerror.Visible = true;
            }
            finally
            {
            }
        }
Exemplo n.º 2
0
        protected void SendLoginMail(string sendaddress)
        {
            try
            {
                string actcode = (string)ViewState["MMerchantCode"] + Guid.NewGuid().ToString().Replace("-", string.Empty);

                string activationCode = Encodings.EncodeTo64(string.Format("{0};{1};{2}",
                                                                           actcode, txtemail.Value.ToString(), (string)ViewState["MMerchantCode"] //ddlState.SelectedValue.ToString()
                                                                           ));

                string url = string.Format("http://{0}{1}", Request.Url.Authority,
                                           ResolveUrl("ActivationEmail.aspx"));
                string urls = string.Format("{0}{1}", url, string.Format("?verify={0}", activationCode)); Console.WriteLine(url);

                string smtpAddress = ConfigurationManager.AppSettings["SMTPHost"];
                int    portNumber  = int.Parse(ConfigurationManager.AppSettings["SMTPPort"]);
                bool   enableSSL   = true;

                string emailFrom = ConfigurationManager.AppSettings["SMTPAddress"];
                string password  = ConfigurationManager.AppSettings["SMTPPassword"];
                string emailTo   = sendaddress;
                string subject   = ConfigurationManager.AppSettings["EmailSubject"];
                string body      = "Dear <p></p><br/> " + sendaddress + ",<p></p><br/> <br/>Your account have sucessfully been created.  <p></p><br/><br><a href=" + urls + "> Activate Here </a> <br/>  <p></p><br/> Thanks you<br/><p></p><p></p>Regards,<p></p><p></p><br/><br/>Mail  Team";


                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress(emailFrom);
                    if (IsValidEmail(sendaddress.ToString()))
                    {
                        mail.To.Add(sendaddress);
                    }

                    mail.Subject    = "Account Notification";
                    mail.Body       = body;
                    mail.IsBodyHtml = true;

                    //SaveMail();

                    using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                    {
                        smtp.Credentials = new NetworkCredential(emailFrom, password);
                        smtp.EnableSsl   = enableSSL;
                        smtp.Send(mail);
                        //sent = true;
                    }
                }
            }
            catch (Exception ex)
            {
                //logger.Error(ex.Message, "Error occured!");
                lblerror.Text    = ex.Message.ToString();
                lblerror.Visible = true;
            }
            finally
            {
            }
        }