/// <summary>
 /// Add an email to the database
 /// </summary>
 /// <param name="email">the email there should be added</param>
 public void addEmailToDB(PopClient.emailStruct email)
 {
     if (getEmailByMessageID(email.messageID).Count == 0)
     {
         sqlCon.Open();
         string sql = @"INSERT INTO Email (MessageID, SenderName, Body, TimeStamp, Cc, Subject, MailTo, Attachment, SenderEmail, Receiver, Seen) VALUES 
                     (@messageID,@senderName,@body,@timeStamp,@cc,@subject,@mailTo,@attachment,@senderEmail,@receiver,@seen)";
         sqlCom = new SQLiteCommand(sql, sqlCon);
         if (String.IsNullOrEmpty(email.messageID))
         {
             email.messageID = "NULL";
         }
         sqlCom.Parameters.Add(new SQLiteParameter("@messageID", email.messageID));
         sqlCom.Parameters.Add(new SQLiteParameter("@senderName", email.senderName));
         sqlCom.Parameters.Add(new SQLiteParameter("@body", WebUtility.HtmlEncode(email.body)));
         sqlCom.Parameters.Add(new SQLiteParameter("@timeStamp", email.timeStamp));
         sqlCom.Parameters.Add(new SQLiteParameter("@cc", email.cc));
         sqlCom.Parameters.Add(new SQLiteParameter("@subject", email.subject));
         sqlCom.Parameters.Add(new SQLiteParameter("@mailTo", email.mailTo));
         sqlCom.Parameters.Add(new SQLiteParameter("@attachment", email.attachment));
         sqlCom.Parameters.Add(new SQLiteParameter("@senderEmail", email.senderEmail));
         sqlCom.Parameters.Add(new SQLiteParameter("@receiver", email.receiver));
         sqlCom.Parameters.Add(new SQLiteParameter("@seen", email.seen));
         sqlCom.ExecuteNonQuery();
         sqlCon.Close();
     }
 }
        /// <summary>
        /// Get emails from the database by the messageID
        /// returns only more then 1 email if its a spam mail
        /// </summary>
        /// <param name="messageID">the messageID</param>
        /// <returns>the list of emails</returns>
        public List <PopClient.emailStruct> getEmailByMessageID(string messageID)
        {
            List <PopClient.emailStruct> emails = new List <PopClient.emailStruct>();

            PopClient.emailStruct email = new PopClient.emailStruct();
            sqlCon.Open();
            string sql = "SELECT * FROM Email WHERE MessageID='" + messageID + "'";

            sqlCom = new SQLiteCommand(sql, sqlCon);
            SQLiteDataReader reader = sqlCom.ExecuteReader();

            while (reader.Read())
            {
                email.messageID   = reader["MessageID"].ToString();
                email.senderName  = reader["SenderName"].ToString();
                email.senderEmail = reader["SenderEmail"].ToString();
                email.body        = WebUtility.HtmlDecode(reader["Body"].ToString());
                email.timeStamp   = reader["TimeStamp"].ToString();
                email.cc          = reader["Cc"].ToString();
                email.subject     = reader["Subject"].ToString();
                email.mailTo      = reader["MailTo"].ToString();
                email.attachment  = reader["Attachment"].ToString();
                email.receiver    = reader["Receiver"].ToString();
                email.seen        = Convert.ToBoolean(reader["Seen"].ToString());
                emails.Add(email);
            }
            sqlCon.Close();
            return(emails);
        }
        /// <summary>
        /// Get emails from the database by the messageID
        /// returns only more then 1 email if its a spam mail
        /// </summary>
        /// <param name="messageID">the messageID</param>
        /// <returns>the list of emails</returns>
        public List<PopClient.emailStruct> getEmailByMessageID(string messageID)
        {
            List<PopClient.emailStruct> emails = new List<PopClient.emailStruct>();
            PopClient.emailStruct email = new PopClient.emailStruct();
            sqlCon.Open();
            string sql = "SELECT * FROM Email WHERE MessageID='" + messageID + "'";
            sqlCom = new SQLiteCommand(sql, sqlCon);
            SQLiteDataReader reader = sqlCom.ExecuteReader();

            while (reader.Read())
            {
                email.messageID = reader["MessageID"].ToString();
                email.senderName = reader["SenderName"].ToString();
                email.senderEmail = reader["SenderEmail"].ToString();
                email.body = WebUtility.HtmlDecode(reader["Body"].ToString());
                email.timeStamp = reader["TimeStamp"].ToString();
                email.cc = reader["Cc"].ToString();
                email.subject = reader["Subject"].ToString();
                email.mailTo = reader["MailTo"].ToString();
                email.attachment = reader["Attachment"].ToString();
                email.receiver = reader["Receiver"].ToString();
                email.seen = Convert.ToBoolean(reader["Seen"].ToString());
                emails.Add(email);
            }
            sqlCon.Close();
            return emails;
        }
 /// <summary>
 /// an item for EmailListShower
 /// </summary>
 /// <param name="_email">PopClient.emailStruct</param>
 /// <param name="_mw">MainWindow</param>
 public EmailListItems(PopClient.emailStruct _email, MainWindow _mw)
 {
     InitializeComponent();
     email = _email;
     mw = _mw;
 }
 /// <summary>
 /// Show the selected email
 /// </summary>
 /// <param name="_email">the email to be shown</param>
 public EmailShower(PopClient.emailStruct _email)
 {
     InitializeComponent();
     email = _email;
 }
 /// <summary>
 /// an item for EmailListShower
 /// </summary>
 /// <param name="_email">PopClient.emailStruct</param>
 /// <param name="_mw">MainWindow</param>
 public EmailListItems(PopClient.emailStruct _email, MainWindow _mw)
 {
     InitializeComponent();
     email = _email;
     mw    = _mw;
 }
Exemple #7
0
 /// <summary>
 /// Show the selected email
 /// </summary>
 /// <param name="_email">the email to be shown</param>
 public EmailShower(PopClient.emailStruct _email)
 {
     InitializeComponent();
     email = _email;
 }