public void SendMail(int SendByUserId, int SendToUserId, string Subject, string _EmailBody)
        {
            MailMessage _objMailMessage = new MailMessage();
            _objMailMessage.SendByUserId = SendByUserId;
            _objMailMessage.Subject = Subject;
            _objMailMessage.Body = _EmailBody;
            _objMailMessage.SendToUserId = SendToUserId;
            _objMailMessage.SendDate = DateTime.Now;
            _objMailMessage.Status = 1;
            _objMailMessage.RecievedDate = DateTime.Now;
            _objMailMessage.CreatedBy = SendByUserId;
            _objMailMessage.CreatedDate = DateTime.Now;
            _objMailMessage.ModifiedBy = SendByUserId;
            _objMailMessage.ModifiedDate = DateTime.Now;
            _objMailMessage.IsActive = true;
            _objMailMessage.IsDeleted = false;
            object[] _ParamMail = { _objMailMessage };
            UserInfoResource objUser = new UserInfoResource();

            if (objUser.SaveEmail(_ParamMail) > 0)
            {
                EmailMessages objEmail = EmailMessages.Instance;

                //to get user details of from user id
                UserRegistration objFromUserInfo = new UserRegistration();
                objFromUserInfo = (UserRegistration)GetUserDetails(SendByUserId);
                //to get user details of TO user id
                UserRegistration objToUserInfo = new UserRegistration();
                objToUserInfo = (UserRegistration)GetUserDetails(SendToUserId);
                if (objToUserInfo.EmailNotification.MessagesNotify)
                {
                    bool val = objEmail.SendMessages("Your " + WebConfig.ApplicationWord + " <" + WebConfig.NoreplyEmail + ">", objToUserInfo.Users.Email, GetEmailSubject(objFromUserInfo), GetEmailBody(objFromUserInfo, objToUserInfo, Subject, _EmailBody), EmailMessages.TextFormat.Html.ToString());
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objValue"></param>
        /// <returns></returns>
        public List<MailMessage> GetMailThread(object[] objValue)
        {
            List<MailMessage> lstTributes = new List<MailMessage>();
            try
            {
                object[] objParam = { int.Parse(objValue[0].ToString()) };
                DataSet _objDataSet = GetDataSet("usp_GetMailThread", objParam);
                int ParantMsgId = 0;
                if (_objDataSet.Tables[0].Rows.Count > 0)
                {

                    foreach (DataRow dr in _objDataSet.Tables[0].Rows)
                    {
                        MailMessage objMailMessage = new MailMessage();
                        //objMailMessage.MessageId = int.Parse(dr["MessageId"].ToString());
                        objMailMessage.SendByUser = dr["SendByUser"].ToString();
                        objMailMessage.Subject = dr["Subject"].ToString();
                        objMailMessage.Body = dr["Body"].ToString();
                        objMailMessage.UserImage = dr["UserImage"].ToString();
                        objMailMessage.SendDate = DateTime.Parse(dr["SendDate"].ToString());
                        objMailMessage.Status = int.Parse(dr["Status"].ToString());
                        objMailMessage.SendByUserId = int.Parse(dr["SendByUserId"].ToString());
                        //objMailMessage.ParantMsgId = int.Parse(dr["ParantMsgId"].ToString());
                        lstTributes.Add(objMailMessage);
                        objMailMessage = null;
                        ParantMsgId = int.Parse(dr["ParantMsgId"].ToString());

                    }
                }
                return lstTributes;

            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                if (sqlEx.Number >= 50000)
                {
                    Errors objError = new Errors();
                    objError.ErrorMessage = sqlEx.Message;
                    MailMessage objMailMessage = new MailMessage();
                    objMailMessage.CustomError = objError;
                    lstTributes.Add(objMailMessage);
                    objMailMessage = null;
                }
                return lstTributes;
            }
        }