how to send message on whatapp number using asp.net 4.0with c#

619 views Asked by At

I just developed one aspx page that have functionalities to send whatsapp message. here i just post my code.

 protected void btnSend_Click(object sender, EventArgs e)
    {
        string from = "919898683714";
        string to = txtTonumber.Text.Trim();//Sender Mobile
        string msg = txtMessage.Text.Trim();
        string password = WhatsAppApi.Register.WhatsRegisterV2.GetToken(from);

        WhatsApp wa = new WhatsApp(from, password, "Shalin",true,false);

        wa.OnConnectSuccess += () =>
        {
            ltrmessage.Text ="Connected to whatsapp...";

            wa.OnLoginSuccess += (phoneNumber, data) =>
            {
                wa.SendMessage(to, msg);
                ltrmessage.Text = "Message Sent...";
            };

            wa.OnLoginFailed += (data) =>
            {
                ltrmessage.Text = "Login Failed :" + data;
            };

            wa.Login();
        };

        wa.OnConnectFailed += (ex) =>
        {
            ltrmessage.Text = "Connection Failed...";
        };

        wa.Connect();
    }

but still i can't send messages from this code.

is there anyone idea about it...

0

There are 0 answers