Send HTML Emails with Python | Free Attendance Script + Tutorial

Download free Python script to send HTML emails with student attendance tables. Step-by-step tutorial for beginners using Gmail SMTP & Python.

Thursday, May 29, 2025
Send HTML Emails with Python | Free Attendance Script + Tutorial

Send HTML Emails with Python – Student Attendance Table Email Script (Free Source Code + Tutorial)

Are you looking for a practical way to automate email sending using Python? Whether you're an educator, a student, or a Python enthusiast, this beginner-friendly tutorial and free source code will help you learn how to send professional-looking HTML emails using Python.

In this post, we’ll walk you through how to create a Python script that sends a styled HTML email containing a student attendance table. The best part? We’ve included the complete source code as a free download – no registration or fees required!


 What This Python Script Does

This script is designed to send an email that includes a formatted HTML table showing the list of students who were present on a specific date (e.g., 29/5/25). The email includes:

  • A subject line: "List of Students Present on 29/5/25"

  • A simple and clean HTML table with roll numbers and student names

  • SMTP authentication using Gmail

  • A sample student attendance list that can be easily modified

This is an excellent solution for teachers, trainers, or developers looking to send structured data via email directly from Python.




 Why You Might Need This

Automating your email system can save a lot of time and reduce manual work. This script can be useful in various scenarios:

  •  Teachers and professors sending daily or weekly attendance reports

  •  Admins managing internal communications

  •  Developers learning to integrate email automation into their Python projects


 Technologies Used

Here are the main Python libraries used in this project:

  • smtplib: For connecting and communicating with the email server

  • email.mime.multipart and email.mime.text: To construct MIME-compliant emails with HTML content

No third-party libraries are required, making it lightweight and easy to run.


 Sample Output

When you run this script, it sends an email that looks something like this:


Subject: List of Students Present on 29/5/25

Body (HTML Table):

Roll No.Student Name
7497Aman
7498Akash
7496Bhanu

 Important Note on Gmail SMTP

To run this script successfully using your Gmail account:

  1. Enable 2-Step Verification in your Gmail account.

  2. Generate an App Password under Google Account > Security > App Passwords.

  3. Replace your Gmail password with this App Password in the script for secure login.


 Free Download

 We’re offering the complete source code in a zip file — 100% free. Whether you're a beginner looking to learn or a professional wanting to reuse the logic, this script is yours to download, modify, and use in your own projects.





 How to Use the Script

  1. Download the ZIP file and extract it to your local machine.

  2. Open the script in any Python IDE or text editor.

  3. Update the sender and receiver email addresses as per your requirement.

  4. Run the script using Python 3.

    python send_email.py


    Once executed, the email will be delivered to the recipient with the formatted HTML content.


     Final Thoughts

    This project is a great stepping stone into the world of email automation with Python. You’ll not only learn how to send emails programmatically, but also how to use HTML to create beautiful, structured messages.

    Whether you're running a class, managing a team, or building tools for internal use, this script is a perfect example of how a few lines of Python can simplify your daily tasks.


    FAQ Section

    ❓ What does this Python script do?

    This Python script allows you to send HTML-formatted emails with a student attendance table. It uses Gmail’s SMTP server to deliver the message.


    ❓ Is this source code free to download?

    Yes! The full source code is completely free to download and use. You can modify it for educational, personal, or non-commercial projects.


    ❓ Do I need any third-party Python libraries?

    No, this script only uses Python’s built-in libraries: smtplib and email. No installation of external packages is required.


    ❓ Can I customize the email content?

    Absolutely! You can update the subject, receiver email, student list, and HTML styling in the script to suit your own use case.


    ❓ Is it safe to use my Gmail account in the script?

    We recommend using App Passwords for Gmail to ensure your account’s security. Never share your real password in plain text.


    ❓ Will this script work with other email providers?

    Yes, with minor adjustments. You can change the SMTP server and port for providers like Outlook, Yahoo, or any custom mail server.


    ❓ What Python version is required?

    The script works best with Python 3.6 and above. Make sure your system has an updated Python interpreter.


    ❓ Who is this script for?

    This tutorial is ideal for:

    • Students learning Python

    • Teachers managing attendance reports

    • Developers testing email features

    • Anyone who wants to automate HTML email sending


      Share Your Thoughts in the Comments Below

      Have you tried the script or customized it for your own project? Got questions, feedback, or ideas for improvement? We’d love to hear from you! Whether you're a beginner learning the basics or a developer exploring new automation tricks with Python, your input can help others in the community too. Scroll down and leave your comments below — let’s connect, discuss, and grow together! ????




Leave a Comment: 👇