public static Boolean FormatBoolean(object value)
 {
     if (value != null && value.Equals(DBNull.Value) == false && value.ToString().Length > 0)
     {
         return(Boolean.Parse(UtilityLib.FormatString(value)));
     }
     else
     {
         return(false);
     }
 }
 public static DateTime?FormatDateForNullable(object value)
 {
     if (value != null && value.Equals(DBNull.Value) == false && value.ToString().Length > 0)
     {
         return(DateTime.Parse(UtilityLib.FormatString(value)));
     }
     else
     {
         return(null);
     }
 }
        public static string SendMail(string toAddress, string subject, string body)
        {
            string msg = string.Empty;

            try
            {
                string fromAddress = System.Configuration.ConfigurationManager.AppSettings["FromEmailAddress"].ToString();
                string password    = System.Configuration.ConfigurationManager.AppSettings["Emailpassword"].ToString();
                string smptHost    = System.Configuration.ConfigurationManager.AppSettings["Emailhost"].ToString();
                int    portNo      = UtilityLib.FormatNumber(System.Configuration.ConfigurationManager.AppSettings["Emailport"].ToString());
                bool   sslEnabled  = UtilityLib.FormatBoolean(System.Configuration.ConfigurationManager.AppSettings["EmailsslEnabled"].ToString());
                bool   UseDefault  = true;

                MailAddress fromMailAddress = new MailAddress(fromAddress);
                MailAddress toMailAddress   = new MailAddress(toAddress);
                SmtpClient  smtp            = new SmtpClient
                {
                    Host                  = smptHost, //"smtp.gmail.com",
                    Port                  = portNo,   //587, //465
                    EnableSsl             = sslEnabled,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = UseDefault,
                    Credentials           = new NetworkCredential(fromMailAddress.Address, password)
                };
                using (MailMessage message = new MailMessage(fromAddress, toAddress)
                {
                    Subject = subject,
                    Body = body,
                    IsBodyHtml = true
                })

                    smtp.Send(message);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                throw ex;
            }
            return(msg);
        }