Sending WhatsApp Message Using C# Coding

Sending WhatsApp messages programmatically is a powerful feature that can enhance communication in various applications. In this comprehensive guide, we'll explore how to send WhatsApp messages using C# coding in a Windows Form application. Before diving into the code, let's set up the necessary tools and understand the process.

Previous Projects with Source Code:

Before we proceed, here are some useful projects with their source code that you might find interesting:

  1. Stock Management System Project With Source Code
  2. Library Management System Project With Source Code
  3. School Management System Project With Source Code

Introduction:

In this article, we'll demonstrate how to send WhatsApp messages through a C# .NET application. The process involves designing a Windows Form application and installing the WhatsApp API to create a WhatsApp object, enabling the application to call specific WhatsApp methods.

Sending Whatsapp message using C# coding

WhatsApp API Installation:

Follow these steps to install the WhatsApp API:

Step : 1 - To Install WhatsApp API Image View and download
Step : 2 - To Install WhatsApp API Image View and  download
Step : 3 - To Install WhatsApp API Image View and  download
Step : 4 - To Install WhatsApp API Image View and  download
Step : 5 - Finish

WhatsApp Registration Tools Download:

To proceed, download the WhatsApp Registration Tools from here.

Getting WhatsApp Password:

Follow these steps to obtain your WhatsApp password:

Step : 1 - To get WhatsApp Password Image View and  download
Step : 2 - To get WhatsApp Password Image View and  download
Step : 3 - To get WhatsApp Password Image View and  download
Step : 4 - To get WhatsApp Password Image View and  download

C# Coding

Now, let's explore the C# code for sending WhatsApp messages. The code involves creating a Windows Form application with a button to send messages.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WhatsApp_Application;
using WhatsAppApi;

namespace WhatsApp_Application
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btn_send_Click(object sender, EventArgs e)
        {
            string from = "9199876543210"; //(Enter Your Mobile Number)
            string to = txt_to.Text;
            string msg = txt_msg.Text;
            WhatsApp wa = new WhatsApp(from, "WhatsAppPassword", "NickName", false, false);
            wa.OnConnectSuccess += () =>
            {
                MessageBox.Show("Connected to WhatsApp...");
                wa.OnLoginSuccess += (phonenumber, data) =>
                    {
                        wa.SendMessage(to, msg);
                        MessageBox.Show("Message Sent...");
                    };
                wa.OnLoginFailed += (data) =>
                    {
                        MessageBox.Show("Login Failed : {0} : ", data);
                    };

                wa.Login();
            };
            wa.OnConnectFailed += (Exception) =>
                {
                    MessageBox.Show("Connection Failed...");
                };           
        }
    }
}

Conclusion:

Sending WhatsApp messages through a C# .NET

VIDEO : Sending WhatsApp Message Using C# Code

Post a Comment

9 Comments

  1. Its Not Dowenloading Dear....

    ReplyDelete
    Replies
    1. you can download from here
      https://github.com/mgp25/WART

      Delete
  2. Great article... but... I think you forgot "wa.Connect();" at the end of code;

    ReplyDelete
  3. Hi Sekhar. Great Post.but while run its showing Status As Connected but LoginStatus as Null so its not executing message send code. can you help me over this.

    ReplyDelete
  4. What is create what's app password to use this app please reply me in aashishtyagig@gmail.Com please help me

    ReplyDelete
    Replies
    1. To Download PasswordToolsGenerator
      https://github.com/mgp25/WART

      Delete
  5. But sir how to create WhatsApp password please reply me soon

    ReplyDelete
  6. Hi the password generator keeps giving me:
    Could not request code using either sms or voice.
    SMS: status: fail, rason: bad token
    Voice: status: fail, reason: bad token.

    I am from south africa and tried this on two devices with different sim cards in and definitely gave the right number with area code. Please can you assist.

    ReplyDelete
  7. I am getting this error when attempting to request for code: Provided number does not match any known patterns for

    ReplyDelete