Send Messages From My WhatsApp web to Another Number using C#.NET

 Hi all....,

Today we will discuss about sending messages through whatsapp web programmatically using c#.net. 

it is not a rocket science. Whatsapp providing many API for your business integration. but these apis are not free. they are providing api to use in web application. We are overriding their web link to send customized  messages. 

follow these steps...

1.  install whatsapp for desktop in your PC and set the account using QR code and your mobile.

  https://www.whatsapp.com/download

2. Open Visual Studio and create a simple windows application form.

3. Place 2 text boxes for number and message.

4. Insert button for calling function.

5.  it will direct you to whatsapp web.




CODE

=================

create a function like this

 private void sendWhatsApp(string number,string message)

        {

            try 

            {

                if (number == "")

                {

                    MessageBox.Show("No number added");

                }

                if (number.Length <= 10)

                {

                    MessageBox.Show("Inidan Code added automatically");

                    number = "+91" + number;

                }

                number = number.Replace(" ", "");


                System.Diagnostics.Process.Start("http://api.whatsapp.com/send?phone=" + number + "&text=" + message);

            }

            catch (Exception ex)

            { 

            }

        }

call the function in button click event

        private void btnSend_Click(object sender, EventArgs e)

        {

            sendWhatsApp(txtNumber.Text, txtMessage.Text);

        }


Enjoy the code.



Comments

  1. how to send image with same way?

    ReplyDelete
    Replies
    1. this is a free method, you can buy api for doing more from WhatsApp.

      Delete
    2. How i can buy api kindly guide

      Delete
  2. can you explain it in more detail, because I am newbie in this field

    ReplyDelete
  3. hello dear,
    thanks for the code. but its not sending the text. how to send it by button click?
    Regards

    ReplyDelete
    Replies
    1. To send message automatically, You need to add timer control and start it while calling sendwhatsap function. As well as you need write down given code in timer tick event.

      private void timer1_Tick(object sender, EventArgs e)
      {
      sec += 1;
      if (sec == 20)
      {
      SendKeys.Send("{ENTER}");
      timer1.Stop();
      sec = 0;
      }
      }

      Delete
  4. It will write the same message to WhatsApp messenger to the specified number, but not send automatically if it is connected. I have to press sent button from desktop WhatsApp Application.
    I there any way to send it automatically from the link http://api.whatsapp.com/send?phone=" + number + "&text=" + message

    ReplyDelete
    Replies
    1. To send message automatically, You need to add timer control and start it while calling sendwhatsap function. As well as you need write down given code in timer tick event.

      private void timer1_Tick(object sender, EventArgs e)
      {
      sec += 1;
      if (sec == 20)
      {
      SendKeys.Send("{ENTER}");
      timer1.Stop();
      sec = 0;
      }
      }To send message automatically, You need to add timer control and start it while calling sendwhatsap function. As well as you need write down given code in timer tick event.

      private void timer1_Tick(object sender, EventArgs e)
      {
      sec += 1;
      if (sec == 20)
      {
      SendKeys.Send("{ENTER}");
      timer1.Stop();
      sec = 0;
      }
      }

      Delete
  5. To send message automatically, You need to add timer control and start it while calling sendwhatsap function. As well as you need write down given code in timer tick event.

    private void timer1_Tick(object sender, EventArgs e)
    {
    sec += 1;
    if (sec == 20)
    {
    SendKeys.Send("{ENTER}");
    timer1.Stop();
    sec = 0;
    }
    }

    ReplyDelete
    Replies
    1. hello,do you know how to send whatsapp message but from asp.net web api. please and thank you

      Delete
  6. hello, could you help with the same thing but by using asp.net mvc for web api. please and thank you

    ReplyDelete

Post a Comment

Popular posts from this blog

How To Develop A Simple Game Using C#

How Can Be A Good Programmer