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:
- Stock Management System Project With Source Code
- Library Management System Project With Source Code
- 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.
WhatsApp API Installation:
Follow these steps to install the WhatsApp API:
Step : 1 - To Install WhatsApp API | |
Step : 2 - To Install WhatsApp API | |
Step : 3 - To Install WhatsApp API | |
Step : 4 - To Install WhatsApp API | |
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 | |
Step : 2 - To get WhatsApp Password | |
Step : 3 - To get WhatsApp Password | |
Step : 4 - To get WhatsApp Password |
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
9 Comments
Its Not Dowenloading Dear....
ReplyDeleteyou can download from here
Deletehttps://github.com/mgp25/WART
Great article... but... I think you forgot "wa.Connect();" at the end of code;
ReplyDeleteHi 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.
ReplyDeleteWhat is create what's app password to use this app please reply me in aashishtyagig@gmail.Com please help me
ReplyDeleteTo Download PasswordToolsGenerator
Deletehttps://github.com/mgp25/WART
But sir how to create WhatsApp password please reply me soon
ReplyDeleteHi the password generator keeps giving me:
ReplyDeleteCould 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.
I am getting this error when attempting to request for code: Provided number does not match any known patterns for
ReplyDeleteNew comments are not allowed.