//Method to fill todoList Details into GridVieew
    protected void FillGridView()
    {
        try
        {
            TodoListBusinessObject obj_TodoListBO = new TodoListBusinessObject();
            obj_TodoListBO.EmailID = (string)Session["EmailID"];

            TodoListBusinessLogicFactory obj_UserTodoListBLF = new TodoListBusinessLogicFactory();
            DataSet coll = obj_UserTodoListBLF.CreateTodoListBLF().GetUserListsBL(obj_TodoListBO);

            if (coll != null)
            {
                UserListsGridView.DataSource = coll.Tables["TodoList_UserLists"];


                UserListsGridView.DataBind();
            }
            else
            {
                DataTable dt = new DataTable();
                UserListsGridView.DataSource = dt;
                UserListsGridView.DataBind();
            }
        }
        catch
        {
            ErrorLabel.Text = "Error Filling GridView";
        }
    }
Exemple #2
0
    //Method to display Specific ID Lists
    protected void MailIDDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            TodoListBusinessObject obj_TodoGetListsBO = new TodoListBusinessObject();
            obj_TodoGetListsBO.EmailID = MailIDDropDownList.SelectedItem.Text;

            TodoListBusinessLogicFactory obj_TodoListsBLF = new TodoListBusinessLogicFactory();
            DataSet lists = obj_TodoListsBLF.CreateTodoListBLF().GetUserListsBL(obj_TodoGetListsBO);


            if (lists != null)
            {
                UserListsGridView.DataSource = lists.Tables["TodoList_UserLists"];

                UserListsGridView.DataBind();
            }
            else
            {
                DataTable dt = new DataTable();
                UserListsGridView.DataSource = dt;
                UserListsGridView.DataBind();
            }
        }
        catch {
            GridViewErrorLabel.Text = "Unable to get EmailId's";
        }
    }
    //Event to send email to entered EmailId
    protected void SendEmailButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (EmailTextBox.Text != null)
            {
                using (StringWriter stringWriter = new StringWriter())
                {
                    using (HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter))
                    {
                        UserListsGridView.RenderControl(htmlTextWriter);
                        StringReader stringReader = new StringReader(stringWriter.ToString());
                        MailMessage  mailMessage  = new MailMessage("*****@*****.**", EmailTextBox.Text);
                        mailMessage.Subject    = "TodoList";
                        mailMessage.Body       = "TodoList:<hr/>" + stringWriter.ToString();
                        mailMessage.IsBodyHtml = true;
                        SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                        smtpClient.Credentials = new System.Net.NetworkCredential()
                        {
                            UserName = "******",
                            Password = "******"
                        };
                        smtpClient.EnableSsl = true;
                        smtpClient.Send(mailMessage);

                        ErrorLabel.Text = "Email Sent Successfully";
                    }
                }
            }
            else
            {
                ErrorLabel.Text = "Please Enter EmailID to send";
            }
        }
        catch (Exception E)
        {
            ErrorLabel.Text = "Please Try Again Later";
        }
    }