private void btnSend_Click(object sender, EventArgs e) { if (wa.ConnectionStatus == ApiBase.CONNECTION_STATUS.LOGGEDIN) { if (!string.IsNullOrEmpty(fileName)) { byte[] img = File.ReadAllBytes(fileName); switch (index) { case 1: wa.SendMessageImage(phoneNumber + "@s.whatsapp.net", img, ApiBase.ImageType.PNG); break; case 2: wa.SendMessageImage(phoneNumber + "@s.whatsapp.net", img, ApiBase.ImageType.JPEG); break; case 3: wa.SendMessageImage(phoneNumber + "@s.whatsapp.net", img, ApiBase.ImageType.GIF); break; } if (webBrowser.Document != null) { HtmlElement pElement = webBrowser.Document.CreateElement("p"); pElement.InnerText = String.Empty; webBrowser.Document.Body.AppendChild(pElement); HtmlElement imgElement = webBrowser.Document.CreateElement("img"); imgElement.SetAttribute("src", fileName); webBrowser.Document.Body.AppendChild(imgElement); } else { webBrowser.DocumentText = "<img src= '" + fileName + "'/>"; } fileName = null; lblPath.Text = "Image ???"; //timer.Start(); } else { //timer.Stop(); if (string.IsNullOrEmpty(txtMessage.Text)) { return; } wa.SendMessage(phoneNumber, txtMessage.Text); if (webBrowser.Document != null) { HtmlElement element = webBrowser.Document.CreateElement("p"); element.InnerText = string.Format("{0}:{1}", Properties.Settings.Default.FullName, txtMessage.Text); webBrowser.Document.Body.AppendChild(element); } else { webBrowser.DocumentText = string.Format("{0}:{1}", Properties.Settings.Default.FullName, txtMessage.Text); } txtMessage.Clear(); txtMessage.Focus(); //timer.Start(); } } }