Effortlessly Send WhatsApp Messages with Image Attachments Using Python and Excel

Now a days we are connecting to our family and friends only through the WhatsApp that one platform to we use for sharing our messages and information.
But in the organizations we have to share the WhatsApp message to our customers then how it possible? we don’t do that to send a message to one by one it’s lot of time consume and it make bore to our self too. Then how can we did that?

There is lot of automation works is available.
On this blog we see how to send a WhatsApp message to N number of customer using excel and python.

Step 1:We have to create a contact list in Excel

here i just using one number

step 2: Now we have to write a python program

import pywhatkit as kit
import pandas as pd
import time

excel_file_path = "F:/Logesh/whatsapp_auto_msg_file_py/test_contact.xlsx"
contact = pd.read_excel(excel_file_path, dtype={'contact': str})
count = 0

for index, row in contact.iterrows():  # Iterate through DataFrame rows
    try:
        image_path = "F:/Logesh/whatsapp_auto_msg_file_py/Slide3.JPG"
        contact_number = row['contact']
        formated_number="+91"+contact_number
        print(formated_number)
        message_file_text ="F:/Logesh/whatsapp_auto_msg_file_py/test.txt"
        with open(message_file_text, encoding='utf8') as f:        
         file_data = f.read()
        kit.sendwhats_image(formated_number, image_path, file_data, 15, False, 10)
        count += 1
        print(f"{count}:- The image sent to {formated_number}")
        time.sleep(15)
    except:
        print("something went to problem")
        print(f"unable to sent the message to this {formated_number}")
print('all done')

Pre requestes:

  • Python IDE or VScode
  • Pywhatkit python pakage
  • Pands python pakage.

Program requestes:

  • Create a text message file for example test.txt
  • Confirm your Image file
  • Create your excel file and store on your folder
  • Install pakages using the comand pip install <package_name>

Once it all fixed you can copy the above code and past it on your IDE then using the command python file_name.py the out put should be shown like below.


Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.