0% found this document useful (0 votes)
14 views35 pages

Computer Front Page Edited (1) Merged Merged

Dzhdhfgjhkhkhkhjgddhdchgjkvkvhkjfdxgdgd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views35 pages

Computer Front Page Edited (1) Merged Merged

Dzhdhfgjhkhkhkhjgddhdchgjkvkvhkjfdxgdgd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

SESSION :- 2024-2025

CLASS :- 12th B
COMPUTER PROJECT
ROLL NO:-

TOPIC : BULK EMAIL SENDER

SUBMITTED TO:- SUBMITTED BY :-


:- MR.G.VELANGANNAN M. MONESH
ACKNOWLEDGEMENT
IN THE ACCOMPLISHMENT OF THIS PROJECT
SUCCESSFULLY MANY PEOPLE HAVE BEST OWNED UPON
ME THEIR BLESSINGS AND THE HEART PLEADGE SUPPORT
, THIS TIME I AM UTILIZING TO THANK ALL THE PEOPLE
WHO HAVE BEEN CONCERNED WITH THIS PROJECT.

PRIMARILY I WOULD LIKE TO THANK GOD FOR BEING


ABLE TO COMPLETE THIS PROJECT WITH SUCCESS . THEN
I WOULD LIKE TO THANK MY SENIOR PRINCIPAL
MR.K.SENTHIL KUMAR FOR PROVIDING ALL FACILITIES
TO SHOW MY FULL POTENTIAL TOWARDS THIS
INVESTIGATORY PROJECT AND MY COMPUTER TEACHER
MR.G.VELANGANNAN WHOSE VALUABLE GUIDANCE
HAS BEEN THE ONE THAT HELPED ME TO PATCH THIS
PROJECT AND MAKE IT FULL PROOF SUCCESS , HIS
SUGGESTIONS AND INSTRUCTION HAS SERVED AS THE
MAJOR CONTRIBUTION TOWARDS THE COMPLETION OF
THIS PROJECT .

THEN I WOULD LIKE TO THANK MY PARENTS WHO HAVE


HELPED ME WITH THEIR VALUABLE SUGGESTIONS AND
GUIDANCE HAS BEEN VERY HELPFUL IN VARIOUS PHASES
OF THE COMPLETION OF THE PROJECT .

SECONDLY I WOULD THANK MY FRIENDS AND


CLASSMATES WHO HELPED ME A LOT IN FINALIZING THIS
PROJECT WITHIN THE LIMITED TIME FRAME .
CERTIFICATE OF EXCELLANCE

ROLL NO :

THIS IS TO CERTIFY THAT M. MONESH STUDENT OF


CLASS 12th B HAS SUCESSFULLY COMPLETED THE
RESEARCH ON THE BELOW MENTIONED PROJECT UNDER
THE GUIDANCE OF MR.G.VELANGANNAN (SUB
TEACHER) DURING THE YEAR OF 2024 – 2025 IN PARTIAL
FULFILLMENT OF PHYSICS PRACTICAL EXAMINATION
CONDUCTED BY ORANGE BRITISH ACADEMY SENIOR
SECONDARY SCHOOL , VINNANMANGALAM – ARNI .

TEACHER IN CHARGE EXAMINER

SCHOOL SEAL & PRINCIPAL’S SIGNATURE


Project Name: Bulk Mailing

INDEX

S.No. Project Content Page No.

1. Scope of the Project

2. About the Project

3. Features of the project

4. Technology Used

5. Advantages of .NET

6. Software and Hardware Requirement

7. Software Development Life Cycle

8. Software Requirement Specification

9. Block Diagram

10. Data Flow Diagram

11. Entity Relationship Diagram

12. Data Diagram

1
The main features of bulk mailing system are...

 We can create a series of messages in advance and decide when they


should be sent to new members.
 Create your own email messages and use built-in templates.
 Import as many email lists as you need creating your own databases.
 Send any type of newsletters, promoting your business, pause sending and
restart when you need it.
 Keep email lists always clean with automatic remover of bounced emails.
 Create your messages with plain text or images that can be .gif and .jpg
formats.
 Import or create mailing lists of various formats.
 Send detailed emails and contact multiple consumers with one click only.
 Perform email marketing with your contact's permission, thus building
good relationships with your customers.

ADVANTAGE OF BULK EMAILING SYSTEM

There are many advantages to using bulk mail. The most important advantage is
that bulk mailing prices are significantly lower than single-piece prices. That can
save you a lot of money.

You can check out the web for e mail marketing tips too there are plenty of sites
you can learn from. There is a lot of email marketing software that will give you a
free trial to see if it is what you want to use as your email marketing solution. Pick
carefully and try out more than one before settling on a program you like.

If you are not sure about the laws and regulations you will be better off hiring
email marketing services to handle your email instead of trying it yourself with
targeted bulk email. It is much better to be safe and hire a service for your
targeted bulk email marketing.

4
People do not like spam and you need to adhere to the rules for that strictly. If
you do not, it is quite possible that you will not be able to send email. If you have
a great site that really needs promotion.
Using bulk emailing software is the effectiveness in the delivery of mail. There is
no point in all this effort to work on if the mail messages went to SPAM Folder!
Using this software email goes to inbox folder.

PROJECT PLAN

Modules involved in the project

 User Panel.
 Admin Panel.

Module 1: User Panel Module

Registration for user: User registration steps …


 Personal Detail: User insert personal detail in this page just like first name, last
name, email id,dob,gender,address,pincode mobile no, phone no etc.
 Reason of using this s/w: User enters the all detail reason to use s/w.

After registration user must validate his/her information.


Send Bulk Mails:
 User can create mail matter using in build templates or plain text and save
permanently.
 User can load the recipient list in csv format or excel format.
 User can pause the mail sender process and again can restart.
 User can save the contact details in database and also search the email
address.
 User can make group according the contacts and add new group.
 User can filter the email address and delete the fake address.
 User can use any type of image to create mail matter.

Module 2: Admin Panel Module

5
Admin should have facility for ….

 Facility to send confirmation code on the email id for verified email id


of user.
 Facility to add, update and delete of whole information of user.
 Facility to view user profile.
 Facility to add email templates.
 Facility to send alerts to users.

TECHNOLOGY USED
The strength of any project depends upon the technology on which the project is
based. Today we are living in a world where technologies related to computer
science are evolving every day new technologies are taking an edge over the older
ones. Every new technology is provides some new benefits, but only small part of
them remains in the competitive world. This project is the result of combining our
knowledge of emailing with the power of .NET technologies. The Project allows to
quickly integrate electronic mail sending and receiving with your .NET
Applications.

NET is the latest technology, which is in use nowadays and has proved to be the
most reliable development framework. The technologies we have used in the
development of the project are:

* ASP.NET

* SQL Server

Why to use .NET?

6
The .NET Framework is a new computing platform that simplifies application
development in the highly distributed environment of the Internet. The .NET
Framework is designed to fulfill the following objectives:

* To provide a consistent object-oriented programming environment whether


objects code is stored and executed locally, executed locally but Internet-
distributed, or executed remotely.

* To provide a code-execution environment that minimizes software deployment


and versioning conflicts.

* To provide a code-execution environment that guarantees safe execution of


code, including by an unknown or semi-trusted third party.

* To provide a code-execution environment that the performance problems of


scripted or interpreted environments

* To make the developer experience consistent across widely varying types of


applications, such as windows-based applications and Web-based applications.

* To build all communication on industry standards to ensure that code based on


the .NET Framework can integrate with any other code.

OTHER TECHNOLOGIES
SQL SERVER:

Microsoft SQL Server 2000 is a family of products that meet the data storage
requirements of the largest processing systems and commercial Web sites, yet at
the same time can provide easy-to-data storage services to an individual or small
business.

7
Software and Hardware Requirements
Software requirements:

* Operating System:

Windows 2000 and above

* Development Environment:

Microsoft Development Environment -4.0

Microsoft .NET Framework 4.0

* Database Server:

Microsoft SQL Server Service Manager version 2008

SQL Query Analyzer

* Languages Used:

VB.NET

ASP.NET

* Word Processor:

Microsoft Word 2007

* Image Processing Tool:

Microsoft Paint

8
* Web Browser:

Microsoft Internet Explorer version 8.0

Hardware Requirements

* Microprocessor

X86 Family 6 Models 8 Stepping 6 GenuineIntel~930 MHZ

* RAM

128 MB

* Hard Disk Space Required

100 MB

* Hard Disk Drive

40 GB

* CD ROM

Samsung CD ROM sc-152c

SDLC

9
INTRODUCTION:

Human is dealing with the data and information since a long time, perhaps since

the beginning of civilization man is manipulating data. Since then, give and take of

information is in practice, but this has been considered as an important discipline

for the last few decades. Today’s data manipulation and information processing

have become the major tasks of any organization small or big, whether it is

educational institution, government concern, scientific, commercial or any other.

Information is the requirement of every organization. Infect, large organizations

have started having information systems whose work is together the necessary

data and to process those data into meaningful information. System is a buzzword

today. Everybody talks of the system such as an educational system,

transportation system, accounting system, financial system, computer system,

and information system. A system is a set of interrelated elements that operate

together to achieve an objective. The general model of system has an inputs,

process and output. A system can have many inputs and many outputs. Most talk

about system is information system. It receives the data and collects the

information and instructions, process the data according to the instructions and

outputs the result which itself has some information. An information system in

which storage methods are also added, the information processing function

10
means not only the transformation of the data into information but also the

storage of the data for later use. The information system receives data as input

and converts them into information.

An information system can comprises of both human and machines. It is not that

an information system simply means machine. Information system uses the

various tools to collect data. These tools can be humans as well as machines. Then

these tools data is processed into information. The data can be processed using

some manual methods or electronic method. Then the information that they get

after processing of data is the output of that information system.

An information system is to an organization, what a nervous system is to the

body. They do not operate independently, but exists in organization to support

the organization process at different levels. Timely information is required at

every level of any organization to take the important decision. To cater the needs

of organization, information systems in any organization, are available at different

levels.

Requirement Analysis:

11
A systematic investigation of a real or planned system to determine the function

of the system and how they relate to each other and to any other system is

known as system analysis.

System analysis is conducted with the following objectives in mind:

 Identify the customer’s need,

 Perform economic and technical analysis,

 Evaluate the system concept for feasibility,

 Allocate functions to hardware, software, people, database and other


system elements,

 Establish cost and schedule constraints,

 Create a system definition that forms the foundation for all subsequent
engineering work.

System Analysis Overview:

Problem recognition means detailed study of the current system being used by

the user. A detailed study of system being currently used must be carried out of

sessions with customer and end user. It can be termed as a process of recognizing

problems and opportunities.

12
A complete understanding of software requirement is essential to the success of a

software development effort. The problem evaluation and solution synthesis is

the next major area of effort for analysis. It enables the system, engine to

redefine the software allocation and build model of process followed

Identification of need

Preliminary investigation

Identification of need:

The first step of the System Analysis process involves the identification of need.

The analyst meets the customer and the end user (if different from the user). The

intent is to understand the products objective and to define the goals required to

meet the objectives. Timely Customer-Analyst communication is an important

ingredient of a system analyst’s work. The specific objectives are:

 Reducing the Duplication during manual Processing

 Designing and Developing User friendly interfaces through which user will
interact with the package

 Interaction of these GUI with the Database

 Managing the Database

 Improve efficiency and quality of services

13
There are a number of factors that needs to be actively handled, the system must

track the data and be able to manage it as well as give the detailed account of the

comparative study in the forms of graphs and reports.

Every system must have some complexity attached with it, which is needed to be

simplified so that we can achieve a system, which is easier, less complex and

easily accessible to the less trained user.

The above stated complexity being faced by the staff in respect of such a large

number of departments and variety of programs being run by each department,

each having its own criteria makes it entice the official to look for a system which

can operate with a such a complex nature of data and be developed in such a way

so that it becomes relatively easier to operate by the end user.

Preliminary investigation:

During the analysis phase of the project, first we decided to sit/talk /and

understand the current workflow. And found that the basic functionality is

divided into 12 major modules, which deals with registration management,

searching for tender management, supplying and purchasing of tender

management, generation of reports for each requirement and searching for many

other facilities etc.

14
Feasibility study:

All the projects are feasible given the unlimited resources and infinite time.

Unfortunately, the development of a computer-based system or product is more

likely to be plagued by the scarcity of resources and difficult delivery dates. It is

both necessary and prudent to evaluate the feasibility of a project at the earliest

possible time. Months or years of effort, thousand or millions of rupees, and

untold professional embarrassment can be averted if an ill-conceived

system is recognized early in the definition phase.

Feasibility and risk analysis are related to each other. If project risk is great, the

feasibility of producing quality software is reduced.

However, we confine our attention to:

 Technical Feasibility.

 Economical Feasibility.

 Operational feasibility.

Technical Feasibility:

A study of function, performance, and constraints that may affect the ability to

achieve an acceptable system. It is the most difficult area to assess because

objectives, functions, and performance are somewhat hazy; anything seems

possible if me right assumptions are made.

15
A clinical attitude should prevail during an evaluation of technical feasibility. The

considerations normally attached with the technical feasibility:

Development Risk:

 Can the system element be designed so that necessary function and


performance are achieved within the constraints uncovered during analysis?

Resource availability:

 Are skilled staffs available to develop the system element in Question? Are any
other necessary resources (hardware and software) available to build the
system?

Technology:

 Has the relevant technology progressed to a state that will support the
system?

 All of the above consideration also applies to the work I have done. As far as
developments risks are concerned, yes necessary functions and the constraints
under which they have to perform have been identified and divided into
modules so that each module perform its own assigned task.

 As for skilled staff for development is concerned, I am the only person


performing this task and I have fully understood the problem. I am sufficiently
equipped with the use of programming and can perform this tasks in the given
time constraints.

The use of programming language enables the programmer to develop software


that can help end-user to operate the system more easily. The use of GUI tool

16
VB.NET and Oracle 8i can be really helpful in case of developing an information
system. The tool comprises of all the components required to solve me problem
system.

Economical Feasibility:
An evaluation of development cost weighed against the ultimate income or
benefit derived from the development system or product. It includes a broad
range of concerns such as:
 Cost-benefit Analysis

 Long-term m corporate income strategies

 Impact on other profits/products

 Cost of resources needed for development

 Potential market growth

 The work being done is economically feasible since the work is not being done
at very large scale, although it might be a bit complex. The cost of resources
needed to do the work was not big. I did receive the necessary monetary help
required to develop this software.

Operational Feasibility:
This study helps us in finding whether the work to be done will be operational
with the available staff and with in the given time. The staff is fully capable of
handling information system. The IT literacy is of good order and the software has
been made in such a way that it becomes easier for the user to answer queries
being asked. This will facilitate easy use and adoptability of the system. Based on
this, it was felt that the proposed system would be operationally feasible. With
17
the use of menus, simple command buttons and proper validation required it
become fully understandable to the common user and operational with the user.

MODEL USED
WATERFALL MODEL:

The waterfall model is a popular version of the systems development life cycle
model for software engineering. Often considered the classic approach to the
systems development life cycle, the waterfall model describes a development
method that is linear and sequential. Waterfall development has distinct goals for
each phase of development. Imagine a waterfall on the cliff of a steep mountain.
Once the water has flowed over the edge of the cliff and has begun its journey
down the side of the mountain, it cannot turn back. It is the same with waterfall
development. Once a phase of development is completed, the development
proceeds to the next phase and there is no turning back

The advantage of waterfall development is that it allows for departmentalization


and managerial control. A schedule can be set with deadlines for each stage of
development and a product can proceed through the development process like a
car in a carwash, and theoretically, be delivered on time. Development moves
from concept, through design, implementation, testing, installation,
troubleshooting, and ends up at operation and maintenance. Each phase of
development proceeds in strict order, without any overlapping or iterative steps.

The disadvantage of waterfall development is that it does not allow for much
reflection or revision. Once an application is in the testing stage, it is very difficult
to go back and change something that was not well-thought out in the concept
stage. Alternatives to the waterfall model include joint application development
(JAD), rapid application development (RAD), synch and stabilize, build and fix, and
the spiral model.

18
SOFTWARE REQUIREMENT SPECIFICATION
A document describing the requirements of a computer system from the user’s
point of view. An SRS document specifies the required behavior the system in
terms of input data, required processing, output data, operational scenarios and
interfaces and the attributes of a system including performance, security,
maintainability, reliability, audit ability, availability and safety requirements and
design constraints. Alias: user requirement specification, functional specification.
19
The software requirement specifications produced at the culmination of the
analysis task. The function and the performance allocated to software as part of
the system engineering are refined by establishing a complete information
description, a detailed functional and behavioral description, an indication of
performance requirements and design constraints, appropriate validation criteria,
and other data pertinent to requirements.

The main area of the I.T. dept, which had to be automated, was described in
module description.

Input/output design

Design is the first step in the development phase for any engineered product or
system. It may be denned as “the process of applying various techniques and
principles for the purpose of defining a device, a process or a system in sufficient
detail to permit its physical realization”. The design of a system is a blueprint, or a
plain for a solution for a system. The design a solution a “how to” approach
compared to analysis, a “what is” orientation. It translates the system
requirements into ways of operating them. Software design sits at the technical
kernel of the software process model that is used. Design is the phase where the
quality is fostered in software development. Design provides us with a
representation of software that can be assessed for quality.

Risk Analysis:

These steps are performed in risk analysis for designing the system because:

 The future of the system is our concern. We identifying what risks might
create problem in the life of the system.

20
 We also identified that what change in the user requirements,
technologies, hardware and all other entries connected to the system will
effects the system.

 Risk Identification:

 We were able to identifying the risk under the following categories: -

 Project risk

 Technical risk

 Business risk

 Following list was identifying under the categories mentioned above:

 Enough number of people was available, as estimated, to complete the


system.

All staff involved in the system was not folly trained on the platform to be used
for die development. We also had to study various things about the platform and
the system.

The staff involved in the system was committed for the entire decision of the
project. The entire member worked fulltime on the system.

Probability of risk:

The probability for the project risks such as schedule, resources, customer,
requirement problems and their impact on the system was negligible. There was a
risk on the technical grounds because the system was developed with a new
technology hence the experience on the tools was taking which faced the
management to think whether the choice made was right or wrong. But a survey

21
done on the use of new platform gave us the confidence of continuing on this
decision. As we know system design is a solution a “how to” approach to the
creation of a new system. This important phase is composed of several steps. It
provides the understanding and procedural details necessary for implementing
the system recommended in the feasibility study.

Several activities were carried out during Design. They were:

 Database design
 Program design

Data base design:

Databases:

Database is an organized logical grouping of related files. In a database, data are


integrated and related so that one set of software programs provide access to all
the data, alleviating many of the problems associated with data file environments.
Therefore, data redundancy, data isolation, and data inconsistency are minimized,
and data can be shared among all users of the data.

Database Management System:

The program (or group of programs) that provides access to a database is known
as a database management system (DBMS). A DBMS contains three major
components:

 A data definition language (DDL) is the language used by programmers to


specify the content and structure of the database. The DDL is essentially

22
the link between the logical and physical views of the database. (“Logical”
refers to the way data are physically stored and processed).

 The data manipulation language (DML) is used with a third/fourth


generation language to manipulate the data in the database.

 Structured Query Language (SQL) is the most popular relational database


language, combining both DML and DDL features.

Logical Data Organization:

There are three basic models for logically structuring database: hierarchical,
network, and relational. Each has its own advantages and disadvantages.

The Hierarchical Database Model:

The hierarchical model relates data be rigid structuring data into an inverted
“tree” in which records contains two elements:

 A single root or master field often called a key, which identifies the type
location, or ordering of the records.
 A variable number of subordinate fields that defines the rest of the data
within the record.

The Network Database Model:

The network model creates relationship amongst data through a linked-list


structure in which subordinate records (called members) can be linked to more
than one parent (called owner).

23
The Relational Database Model:

While organization has been organized in a hierarchical fashion, most


business data have traditionally been organized into tables of tables of columns
and rows, especially accounting and financial data. Hierarchical and network
structures have several disadvantages. All the access paths, directories, and
indices must be specified in advance. Once specified, they are not easily changed
without a major programming effort. Therefore, these designs have low flexibility.

Relational database designs have flexibility in regard to

 Ad hoc queries,

 Power to combine information from different sources,

 Simplicity of design and maintenance,

 Ability to add new records without disturbing existing applications.

Logical Database Design:

It is necessary to develop a conceptual model of data, which specifies the


relationships between data. This is used to group data into a number of tables.
The tables are organized to:

Reduce duplication of data,Simplify functions like adding, deleting and updating


data.

The method of organizing or structuring data into tables is known as


Normalization. The collection of tables of data is called a Database. This analysis is
then used to organized data as relations, normalizing relations, and obtaining a
relational database. This approach we used is based on the one described by
Turban.

24
DATA FLOW DIAGRAM (Level -0)

MEMBER
MASTER

Send create
mail profile

Bulk Mail
System

25
DATA FLOW DIAGRAM (Level -1)

MEMBER
Member REGISTRATION
MASTER
master

CREATE PROFILE

LOGIN PROCESS

After After After


Login Login Login

ADD NEW CONTACT ADD CONTACT CHANGE GROUP

Data store Data store Data store

Add _book account group table

26
Entity Relationship Diagram

entrystatus
Dateofcreation

securityanswer
occupation

lname
dob
password fname

gender phoneno
Member_master

Mem_id
Add2
mobileno
Add1
name
emailcode

mobilecode
securityquestion
Add_book
materialstatus
Mail id
Name groupnameo
groupname sn

userid
Address book
Mail id

MAILdetailsAccountwise

maildetail
datatime

27
System Testing

System Testing is very important issue in system development. During system

testing the system is used experimentally to ensure that the system does not fail

and will run according to its specification producing desired outputs as per the

user expected from it.

In many organization persons other than those who have written it perform

testing, so that the software will be more reliable. Following tests can carry out

the testing of system:

 White Box Testing.

 Black Box Testing.

White Box Testing

White Box Testing, sometimes called glass box testing is a test case design

method that uses the control structure of the procedural design to derive test

cases. White Box Testing considers system to be like a White box, which means

that every thing about the system is known to me. The different programs used in

the system, Procedures used, inputs supplied and I know the outputs produced by

it in advance. Person who has developed it generally carries out White Box testing

46
and he/she tests the system against all odd conditions for extreme values. I tested

all the modules independently. In the testing of each module I tested all the

functionality. Right from ‘New or Add’ to ‘Exit or Close’ and from ‘Move-first’ to

‘Move-last’ all were tested. All the if-else structures with various values supplied

at various times were checked. I checked all the loops used in the system and

checked at their boundaries too.

White Box Testing in the application is carried out in two parts:

 Alpha Test

 Beta Test

Alpha Test:

Alpha test of the application involves testing (checking) the system by testing

each and every part of the system separately. In this test the experts or those

who have made the system test each module of the system for different types of

inputs.

Beta Test:

Beta test involves testing of the system treating the system as a whole and the

complete system is tested for extreme values for finding the output generated by

47
it are as desired or not. I have tested my application by inputting the sample data

and found that my application passed Beta test.

Black Box Testing:

Black Box Testing focuses on the functional requirements of the software. It

uncovers a different class of errors than white box testing methods. The end users

or the ultimate user carries out Black Box testing for whom the system is made or

some one who not knows how the system is being made. Selecting some persons

of the organizations who have to operate on the system can perform this testing

so that they know what inputs to be given to the system for different options and

what should the output generated by the system for those values. To perform this

test I selected some persons from the organization including one senior person

also and tested the application. They then evaluated that whether the system is

working properly or not. They all found the system working according to

specification. Some one who neither knows about the work carried out by the

system nor about how it is developed can even perform this test. Thus testing of

the system by this method can even be done for absurd values, which are

unknowingly entered by the user.

The testing of this project is also done accordingly to these above methods so that

it can fulfill the needs, produce all desired output even in the worst possible

48
CODING FOR BULK EMAIL SENDER

import smtplib

import ssl

from operator import itemgetter, attrgetter

import os

import json

import sys

import pandas as pd

from email.mime.text import MIMEText

from email.mime.multipart import MIMEMultipart

BASE_DIR = os.path.dirname(__file__)

# print(BASE_DIR)

def join_dirs(loc):

return os.path.join(BASE_DIR, loc)

list_loc = join_dirs('output_cleaned.xlsx')

# list_loc = join_dirs('emails(test) - Sheet1.csv')

text_loc = join_dirs('email_text.txt')

html_loc = join_dirs('email_text.html')

cred_loc = join_dirs('credentials.json')

sent_info = join_dirs('sent_info.txt')

# cred_loc = 'credentials.json'
message = MIMEMultipart("alternative")

message["Subject"] = "Collaboration for STEM Education Programs"

'''

Read file and return it's content

'''

def readFile(loc):

with open(loc, 'r') as f:

content = f.read()

return content

with open(cred_loc, 'r') as f:

cred = json.load(f)

text = readFile(text_loc)

html = readFile(html_loc)

part1 = MIMEText(text, 'plain')

part2 = MIMEText(html, 'html')

message.attach(part1)

message.attach(part2)

df = pd.read_excel(list_loc)

list_email = df['E-mail Address']

# Set sent to -1 for rows where email address is not present

df.loc[list_email.isnull(), 'sent'] = -1
# Extract only those dataframes where email value is present

df_email_valid = df[~list_email.isnull()]

context = ssl.create_default_context()

smtp, sender, port, pwd = itemgetter(

'smtp', 'sender', 'port', 'password')(cred)

message["From"] = sender

with smtplib.SMTP_SSL(smtp, port, context=context) as server:

server.login(sender, pwd)

index_sent = df_email_valid.columns.get_loc('sent')

for i, data in df_email_valid.iterrows():

try:

if "To" in message:

message.replace_header("To", data['E-mail Address'])

else:

message["To"] = data['E-mail Address']

server.sendmail(

sender, data['E-mail Address'], message.as_string())

df.loc[i, 'sent'] = 1

except Exception as e:

with open(sent_info, 'a') as f:

f.write(

f'Emails send till index:{i-1}\n Last email was send to {df.loc[i-1]}\n')

print(e)

df.to_excel(os.path.join(BASE_DIR, 'sent.xlsx'))

finally:

df.to_excel(os.path.join(BASE_DIR, 'sent.xlsx'))
print('All emails were sent successfully')

You might also like