//This is the Query Code //1. Adding to the sent or draft table //2. Adding to insert table private void Sent(String value) { //Calling GetValue method GetValue(); //Initialize Time Created = DateTime.Now; String Msbox = ""; String query = ""; //Initialize Query if (value.Equals("Draft")) { query = "INSERT INTO draft (author_id, sender, recipient, subject, body, created, parent_id) VALUES (@author, @sender, @recipient, @subject, @body, @created, @parent)"; Msbox = "Added to Draft"; } else { query = "INSERT INTO outbox (author_id, sender, recipient, subject, body, created, parent_id) VALUES (@author, @sender, @recipient, @subject, @body, @created, @parent)"; Msbox = "Email has been Sent"; } try { //Declaring parameter of the query Command = new MySqlCommand(query, Connect); Command.Parameters.AddWithValue("@author", MainForm.Id); Command.Parameters.AddWithValue("@sender", MainForm.Email); Command.Parameters.AddWithValue("@recipient", Recipient); Command.Parameters.AddWithValue("@subject", Subject); Command.Parameters.AddWithValue("@body", Message); Command.Parameters.AddWithValue("@created", Created); Command.Parameters.AddWithValue("@parent", ID_ParentMessage); if (Recipient.Contains('@')) { //Opening Connection Connect.Open(); Reader = Command.ExecuteReader(); //Closing Connection Connect.Close(); //Adding to inbox if (value.Equals("Send")) { AddToInbox(); } //Show Message on Success MessageBox.Show(Msbox); } else { MessageBox.Show("Email recipient is not valid"); } } catch (Exception ex) { Connect.Close(); //Show Message on Fail MessageBox.Show(ex.Message); } }
protected override bool HasAccess() { return(Recipient.Contains("@") && GetQuery("debug") == "true"); }