Look at given below points:
- Take new webform and give any name.
- Add two textbox one for sender and another is for Message.
- Give the name to the textbox like txtTO, and txtMSG.
- Now add Whatsapp.dll files from my website Not from others.
- Now put that code from my application and run it.
- If any query u can contact me in c# corner Thank You.
Now Add following code in webform .cs file:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using WhatsAppApi;
- using WhatsAppApi.Response;
- using System.ComponentModel;
-
-
-
-
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
-
- }
- protected void BtnSEND_Click(object sender, EventArgs e)
- {
-
- string number ="91**********" ;
- string to = txtTo.Text;
- string msg = txtMSG.Text;
- string password = "*****************************";
- WhatsApp wa = new WhatsApp(number, password, "Nickname", true);
-
- wa.OnConnectSuccess += () =>
- {
- Response.Write("connect");
- wa.OnLoginSuccess += (phoneNumber, data) =>
- {
- Response.Write("connection successfully");
- wa.SendMessage(to, msg);
- Response.Write("Sent Successfully");
-
- };
- wa.OnLoginFailed += (data) =>
- {
- Response.Write("login failed"+data);
- };
- wa.Login();
-
- };
-
- wa.OnConnectFailed += (ex) =>
- {
- Response.Write("connection failed: {0}"+ex.StackTrace);
- };
- wa.Connect();
-
- }
-
- }
Now see Output: