<pre>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MansoorBuildding
{
public partial class WhatsAppForm : Form
{
char[] chary = new char[100];
string[] CleanedString = new string[100];
int len = 0;
public WhatsAppForm()
{
InitializeComponent();
}
private void SendWhatUpMessage(string Message, string Number)
{
try
{
if (Number == "") MessageBox.Show("No number added");
if (Number.Length <= 0)
{
Number = "+966" + Number;
}
System.Diagnostics.Process.Start("https://api.Whatsapp.com/send?phone=" + Number + "&text=" + Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnSendClick(object sender, EventArgs e)
{
int j, counter, Nline;
string[] tempArray = richTextBox1.Lines;
string str = "";
Nline = richTextBox1.Lines.Count();
Nline--;
for (counter = 0; counter < Nline; counter++)
{
System.Diagnostics.Debug.WriteLine(tempArray[counter]);
len = tempArray[counter].Length;
tempArray[counter].CopyTo(0, chary, 0, len);
CleanedString[counter] = "";
for (j = 0; j < len; j++)
CleanedString[counter] += chary[j].ToString();
}
str = "";
for (counter = 0; counter < Nline; counter++)
{
if (counter < Nline - 1) str += CleanedString[counter] + "%0a";
else if (counter == Nline - 1) str += CleanedString[counter];
}
SendWhatUpMessage(str, textBoxMobileNo.Text);
}
public void ClearNumberAndMessage()
{
textBoxMobileNo.Text = "";
richTextBox1.Text = "";
}
}
}