Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Sending WhatsApp Message in .Net

    • 0
    • 3
    • 1
    • 2
    • 9
    • 0
    • 1
    • 0
    • 40.7k
    Comment on it

    This time I am here with a very small article about sending WhatsApp Message from your .Net application.
    You need following things for that.

    1-WART(WhatsApp Registration Tool)
    This a tool with which you can get the password to be used in API.

    2-WhatsApp Api for C#(Highly Unstable Currently and Without any proper documentation)

    3- Any mobile number on which you are not using WhatsApp currently and You will not be using it in future for WhatApp(As your number may be blocked if you send multiple messages. Again the blocking criteria is uncertain and my number was blocked after 3-5 messages !!):-(

     


     

    So first thing first. Download the WhatsApp Api for C# via nuget package manager. If you see a reference of the API in your reference,that's good. Otherwise download the API manually and add the reference.
     

    Now we are all set for creating our application. So create the UI like following(I used WinForms):-

    alt text

    Fig 1-The User Interface

    On the click event of the button write following code:-

     

    string nickname = "Mani";

        string senderp = "your number with country code";
        string password = "your password"; // Obtain it with WART or Yowsup
    
        WhatsApp wa = new WhatsApp(senderp, password, nickname, true);
        wa.OnConnectSuccess += () =>
        {
            Console.WriteLine("Connected");
            wa.OnLoginSuccess += (phoneNumber, data) =>
            {
                MessageBox.Show("Connection success!");
    
                wa.SendMessage(txtNo.Text/* Number */, txtMsg.Text);
                MessageBox.Show("Message sent!");
            };
            wa.OnLoginFailed += (data) =>
            {
                MessageBox.Show("Login failed: {0}", data);
            };
            wa.Login();
        };
        wa.OnConnectFailed += (ex) =>
        {
            MessageBox.Show("Connect failed: {0}", ex.StackTrace);
        };
        wa.Connect();
    
        MessageBox.Show("END");
    

    Where "nickname" is the name you want to appear on behalf of the mobile number(yours) which is defined in "senderp".
    The "password" is the password which we get using the "WART" tool which I'll be telling later.
    txtNo is the the textbox in the UI to which the message is to be sent. You need to add "91" while entering the number(For India) or you can add a dropdown with multiple country codes,the choice is yours.
    I don't think I need to tell you about txtMsg

    Now you are ready to send the message but you need the password.So open the WART.exe. You'll see the user interface something like following:-

    alt text

    Fig 2-WART Screen

    Put you mobile number with country code in the textbox. And press "Check Existing". If you see the following screen,you're good to go:-

    alt text

    Fig 2-WART Response for Mobile Number

    Now click "Request Code" button and one OTP(One Time Password) will be sent to your mobile. Put that OTP in the " Confirm Code TextBox of Step 2" and "Confirm Code" button.
    You'll get the password in the "Step 3" block.

     

    Copy the number and paste it in the place of "your number" in the code written above.
    Similarly copy the password and place it in the place of "your password" in the code written above.
    Now you are done with coding part. Run the application and enjoy sending the messages from you .net application.
     

    There are some limitation of current version of C# API. So Please take them into account while creating the application.(I found them while creating this demo application)

    1-There is almost no documentation of this API for development. All you can do is hours of searching for any new requirement. The PHP API is better.

    2-Highly unstable. You may get into endless loop of connection errors even if you've done everything right from your end or you may get it right in first attempt.

    3-Sending 5 or more message to a mobile number (in my case sending 3 messages overall) may block your number(Criteria me differ as I've seen some people saying that they've sent thousands of messages without getting blocked). There is an idea to check that you number is blocked or not. Just put your mobile number in the WART tool and click "Check Existing". This will tell you if you number is blocked. I couldn't find any idea to unblock it though.

    4-With that said,please do not use your actual WhatsApp number as you may face blocking of the same. That's why I recommended many sim cards.

    So this was the idea of sending WhatsApp message with .NET. Will update you If I find anything useful. Till then try trying this example by keeping 4 points in your mind.:-)
     

    Happy Coding:-)

    Sending WhatsApp Message in .Net

 9 Comment(s)

  • <p>Hi mani141990 </p> <p>Did you get the password from WART Tool? </p> <p>There may be multiple reasons for this:</p> <p>1-You are using already registered no so guys at WhatsApp have blocked it.(I was blocked too and believe me, they are very good at it.:-). Anyways I have mentioned this in the blog too.)</p> <p>2-Try generating password again using the WART Tool if you are lucky and not blocked. You can always check the status using the WART tool.</p> <p>3-The API is not very stable and they are not promoting that actively .</p> <p>So for me it was a hit and trial for nearly two days. So keep trying and send me the line where you are getting error in debugging. I will try to replicate and help.</p> <p>Thank You.</p> <p>Regards-</p> <p>Manvendra Singh</p>
  • Hi sir i try this steps but that,s can reply me your number is block the system (whatsapp) send me pa passcodes but thant, never acceptable and for second time the system reply me your number is black what,s i can do? and how get that,s password , and code to process my next app??? please help me

  • <p>hello admin i have got the password from WRAT tool and iam also using the new NUMBER and iam using this many time and iam getting login failed erreo its connected in whtasapp but not sending the message plz help me out.</p> <p>THNX </p>
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: