public static void SendMessage(TMSG _msg, ConnectorOnEventDelegate _onstart = null, ConnectorOnEventDelegate _onresponse = null, ConnectorOnEventDelegate _onerror = null)
 {
     if (_onstart != null)
         _onstart(_msg);
     SmtpClient smtp = new SmtpClient(Config.EMAILAuth.URL);
     if (Config.EMAILAuth.Login != "")
         smtp.Credentials = new System.Net.NetworkCredential(Config.EMAILAuth.Login, Config.EMAILAuth.Password);
     else
         smtp.UseDefaultCredentials = true;
     _msg.ExternalID = _msg.ID;
     try
     {
         MailMessage msg = new MailMessage();
         msg.From = new MailAddress("ППФ Страхование Жизни <*****@*****.**>");
         msg.IsBodyHtml = true;
         msg.HeadersEncoding = Encoding.UTF8;
         msg.BodyEncoding = Encoding.UTF8;
         msg.To.Add(_msg.Address);
         msg.Subject = _msg.TopicString;
         msg.Body = _msg.Text;
         smtp.Send(msg);
     }
     catch (Exception _ex)
     {
         TLogger.Add("Отправка сообщения EMail. Не удалось отправить сообщение EMail! EXCEPTION: " + _ex.Message, TLogger.MSGType.eEmail);
         _msg.ExternalID = -1;
     }
     if (_onresponse != null) _onresponse(_msg);
 }
 public static void SendMessage(TMSG _msg, ConnectorOnEventDelegate _onstart = null, ConnectorOnEventDelegate _onresponse = null, ConnectorOnEventDelegate _onerror = null)
 {
     if (_onstart != null)
         _onstart(_msg);
     _msg.ExternalID = _msg.ID;
     if (_onresponse != null)
         _onresponse(_msg);
 }
 public static int InsertMSG(TMSG _msg)
 {
     SqlCommand sqlcmd = new SqlCommand("INSERT INTO MSGBody VALUES (0,'" + _msg.Address + "','" + _msg.Text + "',2,NULL,NULL,NULL,NULL," + (int)_msg.Channel + ",NULL); SELECT @@IDENTITY;");
     int retval = -1;
     try
     {
         retval = TMSSQLConnector.ExecuteSQLCommand(sqlcmd);
     }
     catch (Exception _ex)
     {
         TLogger.Add("Невозможно исполнить InsertMSG! EXCEPTION: " + _ex.Message, TLogger.MSGType.eEmail);
     }
     return retval;
 }
 public static void SendMessage(TMSG _msg, ConnectorOnEventDelegate _onstart = null, ConnectorOnEventDelegate _onresponse = null, ConnectorOnEventDelegate _onerror = null)
 {
     if (_onstart != null)
         _onstart(_msg);
     string retval = "";
     try
     {
         string msg = "BitrixLogin="******"&BitrixPassMD5=" + Config.CABAuth.Password + "&ID=" + _msg.Address + "&TEXT=" + _msg.Text;
         //UTF8Encoding encoding = new UTF8Encoding();
         //byte[] postBytes = encoding.GetBytes(msg);
         retval = THTTP.Post(Config.CABAuth.URL, msg, _onresponse, _onerror);
     }
     catch
     {
         _msg.ExternalID = -1;
     }
     if (retval == "created")
         _msg.ExternalID = _msg.ID;
     else
         _msg.ExternalID = -1;
     if (_onresponse != null)
         _onresponse(_msg);
 }
 /// <summary>
 /// Получить сообщения для отправки
 /// </summary>
 /// <returns>Массив сообщений для отправки</returns>
 public static List<TMSG> GetMessages()
 {
     List<TMSG> retval = new List<TMSG>();
     DataSet ds = new DataSet();
     try
     {
         ds = TMSSQLConnector.ExecuteProcRetDS("MSGBodyGetToSend");
     }
     catch (Exception _ex)
     {
         TLogger.Add("Невозможно исполнить MSGBodyGetToSend! EXCEPTION: " + _ex.Message, TLogger.MSGType.eEmail);
     }
     if (ds != null && ds.Tables.Count>0)
     {
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             try
             {
                 retval.Add(TMSG.FromDataRow(dr));
             }
             catch (Exception _ex)
             {
                 int id = -1;
                 int.TryParse(dr["ID"].ToString(), out id);
                 if (id > 0)
                 {
                     TMSG msg = new TMSG();
                     msg.ID = id;
                     msg.ExternalID = -1;
                     DBQuery.UpdateMSGStatus(msg);
                 }
                 TLogger.Add("Невозможно преобразовать строку БД к требуему виду! Сообщение ID=" + id + " EXCEPTION: " + _ex.Message, TLogger.MSGType.eEmail);
             }
         }
     }
     return retval;
 }
 /// <summary>
 /// Обновить статус сообщения в БД
 /// </summary>
 /// <param name="_msg">Сообщение</param>
 public static void UpdateMSGStatus(TMSG _msg)
 {
     List<SqlParameter> param = new List<SqlParameter>();
     param.Add(new SqlParameter("ID", _msg.ID));
     param.Add(new SqlParameter("Status", (int)_msg.DBStatus));
     param.Add(new SqlParameter("ExtID", _msg.ExternalID));
     try
     {
         TMSSQLConnector.ExecuteProcRetString("MSGBodySetStatus", param);
     }
     catch (Exception _ex)
     {
         TLogger.Add("Невозможно исполнить MSGBodySetStatus с сообщением ID=" + _msg.ID + " EXCEPTION: " + _ex.Message, TLogger.MSGType.eEmail);
     }
 }