Communicate With Whatsapp From Website In C#

Look at given below points:

  1. Take new webform and give any name.
  2. Add two textbox one for sender and another is for Message.
  3. Give the name to the textbox like txtTO, and txtMSG.
  4. Now add Whatsapp.dll files from my website Not from others.
  5. Now put that code from my application and run it.
  6. If any query u can contact me in c# corner Thank You.

Now Add following code in webform .cs file:

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Threading;  
  5. using System.Web;  
  6. using System.Web.UI;  
  7. using System.Web.UI.WebControls;  
  8. using WhatsAppApi;  ///when ur using this application U must use whatsapp.dll file from this application and not use from other sites  
  9. using WhatsAppApi.Response;  
  10. using System.ComponentModel;  
  11.   
  12. // NOTE 1:-  If Your Not Use Whatsapp.dll from my apllication than u get Unauthorized error !!!!!!!!!!  
  13. // NOTE 2 :- Your Phone Number NOT register in any whatsapp account  and u must use number which is not use  in whatsapp account and future use  
  14.   
  15. public partial class _Default : System.Web.UI.Page  
  16. {  
  17.       protected void Page_Load(object sender, EventArgs e)  
  18.     {  
  19.          
  20.     }  
  21.     protected void BtnSEND_Click(object sender, EventArgs e)  
  22.         {  
  23.          
  24.          string number ="91**********" ; // use number which is register from WART tool  
  25.          string to = txtTo.Text;   
  26.          string msg = txtMSG.Text;         
  27.          string password = "*****************************"// use here password which is generated from WART tool              
  28.           WhatsApp wa = new WhatsApp(number, password, "Nickname"true); // nickname u can provide any name  
  29.            
  30.         wa.OnConnectSuccess += () =>  
  31.         {  
  32.             Response.Write("connect");  
  33.             wa.OnLoginSuccess += (phoneNumber, data) =>  
  34.             {  
  35.                 Response.Write("connection successfully");  
  36.                 wa.SendMessage(to/* Number */, msg);  
  37.                 Response.Write("Sent Successfully");  
  38.                  
  39.             };            
  40.             wa.OnLoginFailed += (data) =>  
  41.             {  
  42.                 Response.Write("login failed"+data);  
  43.             };  
  44.                       wa.Login();  
  45.              
  46.         };               
  47.         
  48.         wa.OnConnectFailed += (ex) =>  
  49.         {  
  50.             Response.Write("connection failed: {0}"+ex.StackTrace);  
  51.         };  
  52.         wa.Connect();  
  53.       
  54.     }  
  55.   
  56. }   
Now see Output:

output