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