using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace CKUERA { public partial class CampaWhats : Form { public CampaWhats() { InitializeComponent(); } private void Txt_Mensaje_TextChanged(object sender, EventArgs e) { int i = 700 - Txt_Mensaje.TextLength; label1.Text = i.ToString("#,##0") + " caracteres restantes."; } Principal principal = new Principal(); public string Mje = ""; public string Tel = ""; public string Nombre = ""; public string Firma = "Atentamente,\n*_" + Global.Nom_EMPRESA + "_*\n" + Global.Tel_EMPRESA; public string Obs = "\n\n_*NO RESPONDER.* Este es un mensaje automático. Si desea puede ponerse en contacto a través del teléfono de la empresa._\n\n"; public string NoSpam = "_*NO AL SPAM.* Si ya no desea recibir este tipo de mensaje, contacte al " + Global.Tel_EMPRESA + " y comuniquelo._"; private void button1_Click(object sender, EventArgs e) { if (NumSolo.Text.Length > 8) { Mje = "Estimad@ \n*" + Nombre + "*\n\n" + Txt_Mensaje.Text.Trim() + "\n\n"; EnviarWhats(); this.Close(); MessageBox.Show("Mensaje enviado."); return; } //this.Cursor = Cursors.WaitCursor; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create("http://" + Global._host + "/ecv/clientes_listar.php"); rq.Method = "POST"; byte[] byteArray = Encoding.UTF8.GetBytes(string.Format("nu={0}▼{1}", "", "")); rq.ContentType = "application/x-www-form-urlencoded"; rq.ContentLength = byteArray.Length; Stream stream = rq.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); // WebResponse response = rq.GetResponse(); stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string devuelve = reader.ReadToEnd(); reader.Close(); stream.Close(); response.Close(); string resultado = devuelve.ToUpper(); bool re; re = resultado.Contains(" 8) { string[] t; t = valores[3].Trim().Split(';'); Nombre = valores[1].Trim(); Tel = t[0].Trim(); Mje = "Estimad@ \n*" + Nombre + "*\n\n" + Txt_Mensaje.Text.Trim() + "\n\n"; EnviarWhats(); } } MessageBox.Show("Mensajes enviados."); } this.Close(); } private void EnviarWhats() { string Telefono = ""; if (Tel.Length > 8) { if (Tel.Length < 12)//SI NO ES FORMATO INTERNACONAL { Telefono = Global.Tel_WhatsApp.Substring(0, 3) + Tel; } else//SI ES FORMATO INTERNACONAL { Telefono = Tel; } } principal.EnviarWhatsApp(Global.ID_WhatsApp, Mje+Firma+Obs+NoSpam, Telefono); principal.Espera(); } private void CampaWhats_Load(object sender, EventArgs e) { } } }