Send Image in Skype Chat using Python

In this post, we will send an image to the Skype contact programmatically using Python. Before starting with the code, install the python module skpy. Go to any command line and enter the below command.

pip install skpy

You will have to enter the password of your Skype account in the Base64 encoded form. Learn to encode the string to Base64 using Python.

Python Code

from skpy import Skype
import base64
import traceback

username = "<Skype account Email>"
password = "<Base64 Encoded Skype Password>"

try:
    # connect to Skype
    skype_connect = Skype(username, base64.b64decode(password.encode('utf-8')).decode('utf-8')) 
    chat = skype_connect.contacts["live:<Your Contact User id>"].chat
    filePath = "C:/Users/Pictures/images.png"
    name = "images.png"
    chat.sendFile(open(filePath, "rb"), name, image=True) # file upload
    print(chat.getMsgs())
except:
    print("An exception occurred")
    traceback.print_exc()

Output

Thank you All!!! Hope you find this useful.


Leave a Reply

Up ↑

Discover more from JD Bots

Subscribe now to keep reading and get access to the full archive.

Continue reading