public void ReturnSMTPInfo(out string mailFromDisplay, out string mailFrom,
            out string userName, out string password, out string smtp,
            out int smtpPort, out bool enableSsl)
        {
            mailFromDisplay = string.Empty;
            mailFrom = string.Empty;
            userName = string.Empty;
            password = string.Empty;
            smtp = string.Empty;
            smtpPort = 0;
            enableSsl = false;

            using (MyDataClassesDataContext myDb = new MyDataClassesDataContext())
            {
                var emailInfo = from ei in myDb.EmailSettings
                                select ei;

                foreach (var data in emailInfo)
                {
                    mailFromDisplay = data.MailFromDisplay;
                    mailFrom = data.EmailAddress;
                    userName = data.UserName;
                    password = data.Password;
                    smtp = data.SMTP;
                    smtpPort = Convert.ToInt32(data.SMTP_Port);
                    enableSsl = Convert.ToBoolean(data.EnableSSL);
                }
            }
        }
Example #2
0
        protected void Create_User_Click(object sender, EventArgs e)
        {
            MyDataClassesDataContext dbContext = new MyDataClassesDataContext();

            using (dbContext)
            {
                if (dbContext.Users.Where(Users => Users.Email == Email.Text).Any())
                {
                    //User exist's
                    CheckText.Text    = "Username exist, try to log in.";
                    TestPanel.Visible = true;
                }
                else
                {
                    //Username doesn't exist.
                    User newUser = new User
                    {
                        FirstName = Fname.Text,
                        LastName  = Lname.Text,
                        Email     = Email.Text,
                        Password  = Password.Text
                    };
                    dbContext.Users.InsertOnSubmit(newUser);
                    dbContext.SubmitChanges();

                    Session["UserData"]    = Fname.Text + " " + Lname.Text;
                    Session["NewUserName"] = Email.Text;
                    Response.Redirect("Default.aspx");
                }
            }
        }
Example #3
0
 protected void Submit_Login(object sender, EventArgs e)
 {
     using (MyDataClassesDataContext dbContext = new MyDataClassesDataContext())
     {
         List <User> logged_user = dbContext.Users.Where(Users => Users.Email == Email.Text && Users.Password == Password.Text).ToList();
         if (logged_user.Any())
         {
             //Right login input
             Session["UserData"]    = logged_user[0].FirstName + " " + logged_user[0].LastName;
             Session["NewUserName"] = Email.Text;
             Response.Redirect("Default.aspx");
         }
         else
         {
             //Wrong login input
             CheckText.Text    = "Wrong login input, please try again.";
             TestPanel.Visible = true;
         }
     }
 }
        private void InsertIntoNewletterList(string emailAddress)
        {


            using (MyDataClassesDataContext myDb = new MyDataClassesDataContext())
            {

                // if name is in the database, do not re-add
                int newsletterDb = (from nl in myDb.NewletterLists
                                   where nl.EmailAddress == emailAddress
                                   select nl).Count();

                if (newsletterDb == 0)
                {

                    NewletterList newEmail = new NewletterList();
                    newEmail.EmailAddress = emailAddress;
                    newEmail.IsActive = true;
                    newEmail.DateAdded = DateTime.Now.AddHours(-4);

                    try
                    {
                        myDb.NewletterLists.InsertOnSubmit(newEmail);

                        myDb.SubmitChanges();
                        this.NewsletterButton.Text = "Sent";
                        this.lblSendLabel.Text = "";
                    }
                    catch (Exception ex)
                    {
                        this.lblSendLabel.Text = String.Format("Exception caught in Join Newsletter(): {0}",
                            ex.ToString());
                    }
                }
                else
                {
                    this.lblSendLabel.Text = "Email Address Already Exists In Database";
                }
            }
        }