How to Write a Bulk Emails Application in Vb.Net and Mysql: Step by Step Fully Working Program
()
About this ebook
When I start writing programs and market them, I had a problem on finding an easy way to solve my problems, I found a lot of documents and articles talking about different subjects and I have to go through all of them to find what Im looking for, I was always asking the same question, and I guess a lot of you, are doing the same: why they dont just give an example so people can try it, see how it works and this is how we get better.
In this book we will learn how to develop a program from A to Z, I will try to guide you step by step. For sure, all codes here could be better optimized but this is not the goal of this book, the goal is to put on hands a fully working example.
I found once this article on the internet, it inspires me a lot and I guess it resumes the final aim of this book, the author says: I think human beings in general are great innovators, but only after a period of copying first. Essentially, the "great copying" period is necessary to build a foundation of knowledge and resources, innovation just doesn't come from out of nowhere, all by itself. You don't get to build a skyscraper if you don't have the steel, glass and concrete needed to actually make the thing.
Lotfi Ferchichi
Author Biography Coming Up Soon
Related to How to Write a Bulk Emails Application in Vb.Net and Mysql
Related ebooks
Visual Basic Programming:How To Develop Information System Using Visual Basic 2010, A Step By Step Guide For Beginners Rating: 4 out of 5 stars4/5ASP.NET Application Development Fundamentals Rating: 0 out of 5 stars0 ratingsSQL| KILLING STEPS TO INTRODUCE SQL DATABASES Rating: 0 out of 5 stars0 ratingsThe Dev-c++ Reference Manual Rating: 5 out of 5 stars5/5Excel Custom Functions: Straight to the Point Rating: 0 out of 5 stars0 ratingsUse LibreOffice Base: A Beginners Guide Rating: 0 out of 5 stars0 ratingsThe Definitive Guide to Getting Started with OpenCart 2.x Rating: 0 out of 5 stars0 ratingsVue.js: Tools & Skills Rating: 0 out of 5 stars0 ratingsProgramming ASP.NET Rating: 0 out of 5 stars0 ratingsSalesforce Developer Interview Questions: 1.0, #1 Rating: 0 out of 5 stars0 ratingsA Step By Step Tutorial Using JSP For Web Development With Derby Database Rating: 0 out of 5 stars0 ratingsOpenCart Tips and Tricks Rating: 0 out of 5 stars0 ratingsC# Interview Questions, Answers, and Explanations: C Sharp Certification Review Rating: 5 out of 5 stars5/5Make Bootstrap Themes Rating: 0 out of 5 stars0 ratingsPerformance Project Rating: 0 out of 5 stars0 ratingsSvelte: A Beginner's Guide Rating: 0 out of 5 stars0 ratingsVisual Basic .NET for complete beginners Rating: 5 out of 5 stars5/5Automating Access Databases with Macros Rating: 5 out of 5 stars5/5Spring Boot Intermediate Microservices: Resilient Microservices with Spring Boot 2 and Spring Cloud Rating: 0 out of 5 stars0 ratingsBasics with Windows Powershell Rating: 0 out of 5 stars0 ratingsThe Complete Powershell Training for Beginners Rating: 0 out of 5 stars0 ratingsBlazor and API Example: Classroom Quiz Application Rating: 0 out of 5 stars0 ratingsSave Your Time with VBA!: 5 Quality VBA Books In One Package! Rating: 0 out of 5 stars0 ratingsCreating add-ons for Blender Rating: 5 out of 5 stars5/5Microsoft Access for Beginners and Intermediates Rating: 0 out of 5 stars0 ratingsExcel Macros - A Step-by-Step Illustrated Guide to Learn Excel Macros Rating: 0 out of 5 stars0 ratingsJump Start Git Rating: 0 out of 5 stars0 ratingsMicrosoft Word for Beginners and Intermediates Rating: 0 out of 5 stars0 ratingsVBA for Excel: Programming VBA Macros - The Easy Introduction for Beginners and Non-Programmers Rating: 3 out of 5 stars3/5
Teaching Methods & Materials For You
Dumbing Us Down - 25th Anniversary Edition: The Hidden Curriculum of Compulsory Schooling Rating: 4 out of 5 stars4/5Jack Reacher Reading Order: The Complete Lee Child’s Reading List Of Jack Reacher Series Rating: 4 out of 5 stars4/5Grit: The Power of Passion and Perseverance Rating: 4 out of 5 stars4/5Lies My Teacher Told Me: Everything Your American History Textbook Got Wrong Rating: 4 out of 5 stars4/5The 5 Love Languages of Children: The Secret to Loving Children Effectively Rating: 4 out of 5 stars4/5The Lost Tools of Learning Rating: 5 out of 5 stars5/5Fluent in 3 Months: How Anyone at Any Age Can Learn to Speak Any Language from Anywhere in the World Rating: 3 out of 5 stars3/5Personal Finance for Beginners - A Simple Guide to Take Control of Your Financial Situation Rating: 5 out of 5 stars5/5Inside American Education Rating: 4 out of 5 stars4/5How to Take Smart Notes. One Simple Technique to Boost Writing, Learning and Thinking Rating: 4 out of 5 stars4/5Closing of the American Mind Rating: 4 out of 5 stars4/5Speed Reading: Learn to Read a 200+ Page Book in 1 Hour: Mind Hack, #1 Rating: 5 out of 5 stars5/5The Chicago Guide to Grammar, Usage, and Punctuation Rating: 5 out of 5 stars5/5Weapons of Mass Instruction: A Schoolteacher's Journey Through the Dark World of Compulsory Schooling Rating: 4 out of 5 stars4/5Principles: Life and Work Rating: 4 out of 5 stars4/5Financial Feminist: Overcome the Patriarchy's Bullsh*t to Master Your Money and Build a Life You Love Rating: 5 out of 5 stars5/5Speed Reading: How to Read a Book a Day - Simple Tricks to Explode Your Reading Speed and Comprehension Rating: 4 out of 5 stars4/5Becoming Cliterate: Why Orgasm Equality Matters--And How to Get It Rating: 4 out of 5 stars4/5The Three Bears Rating: 5 out of 5 stars5/5Raising Human Beings: Creating a Collaborative Partnership with Your Child Rating: 4 out of 5 stars4/5How To Be Hilarious and Quick-Witted in Everyday Conversation Rating: 5 out of 5 stars5/5A Failure of Nerve: Leadership in the Age of the Quick Fix (10th Anniversary, Revised Edition) Rating: 4 out of 5 stars4/5A study guide for Frank Herbert's "Dune" Rating: 3 out of 5 stars3/5Summary of The Dawn of Everything by David Graeber and David Wengrow Rating: 4 out of 5 stars4/5The Call of the Wild and Free: Reclaiming the Wonder in Your Child's Education, A New Way to Homeschool Rating: 4 out of 5 stars4/5
Reviews for How to Write a Bulk Emails Application in Vb.Net and Mysql
0 ratings0 reviews
Book preview
How to Write a Bulk Emails Application in Vb.Net and Mysql - Lotfi Ferchichi
HOW TO WRITE A BULK EMAILS APPLICATION IN
VB.NET AND MYSQL
_____________
Step By Step Fully Working Program
Lotfi Ferchichi
Copyright © 2014 by Lotfi Ferchichi.
All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without permission in writing from the copyright owner.
Rev. date: 01/23/2014
To order additional copies of this book, contact:
Xlibris LLC
1-800-455-039
www.Xlibris.com.au
Orders@Xlibris.com.au
524619
Powerfull Product
I believe this kind of software could be a powerful product you can customize and market, this tool answers the question how to send thousands of emails, it can use unlimited number of SMTP servers and can use many instances to maximize the the profit of these servers.
I have put here a lot of commons and very handy functions that can be used with any kind of software, I have put a strong class to manage all the connections with database, the SQL scripts and almost everything related to databases, you will discover after using this class that you have in hand a powefull class that allows you to master all the database headache.
What we need to start?
We will need the following:
– Visual studio .net
– MySQL server
– Framework 4.5.1
Note that we are not taking care of the design; this is something you have to take care of yourself.
No more talking, let’s start
Open visual studio .net and click on New Project
From the framework combo box choose .NET Framework 4.5.1
On the text box Name
, write emails_bulker, and try to keep the same names so you won’t lose yourself later on.
image001.jpgClick on ok, you will have your project ready
image002.jpgLet’s write some quick info, click on the form and go to the properties window (mine is on the right), go the text property and write Email Bulker V1.0.
image003.jpgNote: if you are not seeing the properties window, please go to menu View -> Properties Window
image004.jpgSave the project, click on the button save
image005.jpgClick on button Save.
Usually I organize my files into folders, so let’s create a main folder where we will store our main objects like the form we just created.
So let’s create a folder and call it MAIN
Right click on the project name -> Add -> New Folder
image006.jpg– Rename the new folder to MAIN
– Right click on FROM1.vb and then cut it
– Right Click on our new folder MAIN and click on Paste
Now let’s rename our form to frm_startup.vb
image007.jpgNow, we will add our design,
First I will change the size of my form to 805, 465 or you can set any size you want
image008.jpgI’m going to add a statusStrip.
image009.jpgAnd also, I will add a TabControl.
image010.jpgSet the dock to fill
image011.jpgWe remove the second Tab, so go again the properties window and click on Tab Pages
image012.jpgSelect the TabPage2 and click on remove
image013.jpgAnd rename the first tab to Log
image014.jpgNow click on OK.
Now we will add a new listview where we will display all logs, from the toolbox, look for listview
image015.jpgSelect the listview from the toolbox and add it the form
image016.jpgNow we add the columns, on the properties window click on columns
image017.jpgThis dialog will pop up, click on button Add to add the column
image018.jpgYe should add the following columns
image019.jpgNow we change the view to details, go to properties window and choose view and change it to Details
image020.jpgNow, I guess you know how to change the dock to fill
You can resize the columns size, move the mouse over the column border and you will be able to change the size.
image021.jpgNow we add a timer control, again, go to the toolbox and look for timer
image022.jpgSet the interval to 1000 (1 second)
image023.jpgInstalling MySQL server and creating our database
Go to MySQL website, download and install the server, this is the link where you can get the installer http://dev.mysql.com/downloads/installer/
Don’t forget to install the workbench we will use it a lot.
Database SQL script
Once everything is well installed, let’s start the workbench
Create a new database and call it emails_bulk_messages
image024.jpg– This is the database script, copy and paste it in the SQL query box and run it to create your database
CREATE DATABASE IF NOT EXISTS emails_bulk_messages
USE emails_bulk_messages;
DROP TABLE IF EXISTS eb_activities;
CREATE TABLE eb_activities (
id int(11) NOT NULL,
receiver_id int(11) DEFAULT NULL,
message_id int(11) DEFAULT NULL,
eb_system_message text,
post_date datetime DEFAULT NULL,
eb_email varchar(45) DEFAULT NULL,
PRIMARY KEY (id),
KEY act_key_idx (message_id),
CONSTRAINT act_key FOREIGN KEY (message_id) REFERENCES eb_messages (id) ON DELETE CASCADE ON UPDATE CASCADE
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS eb_email_addresses;
CREATE TABLE eb_email_addresses (
id bigint(20) NOT NULL,
hm_email varchar(245) DEFAULT NULL,
hm_status int(11) DEFAULT ‘1’,
source_file_name varchar(45) DEFAULT NULL,
hm_next_use_date datetime DEFAULT NULL,
hm_priority int(11) DEFAULT ‘10’,
hm_trial_number int(11) DEFAULT ‘0’,
PRIMARY KEY (id)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS eb_messages;
CREATE TABLE eb_messages (
id int(11) NOT NULL,
subject text,
eb_body longtext,
sender_name varchar(245) DEFAULT NULL,
sender_email varchar(245) DEFAULT NULL,
reply_to_email varchar(245) DEFAULT NULL,
post_date datetime DEFAULT NULL,
message_key varchar(245) DEFAULT NULL,
eb_status varchar(45) DEFAULT ‘pending’,
eb_number_of_messages int(11) DEFAULT ‘0’,
eb_report_check_date datetime DEFAULT NULL,
eb_is_report_message int(11) DEFAULT ‘1’,
eb_message_type int(11) DEFAULT ‘3’,
eb_html_body longtext,
eb_next_try_date datetime DEFAULT NULL,
eb_sent_date datetime DEFAULT NULL,
eb_attached_files text,
eb_instance_number int(11) DEFAULT ‘0’,
PRIMARY KEY (id)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS eb_receivers;
CREATE TABLE eb_receivers (
id int(11) NOT NULL,
eb_email varchar(245) DEFAULT NULL,
eb_name varchar(245) DEFAULT NULL,
eb_message_id int(11) DEFAULT NULL,
eb_status varchar(45) DEFAULT ‘pending’,
eb_try_number int(11) DEFAULT ‘0’,
eb_last_used_host text,
eb_instance_number int(11) DEFAULT ‘0’,
eb_priority int(11) DEFAULT ‘10’,
eb_next_try_date datetime DEFAULT NULL,
PRIMARY KEY (id),
KEY msg_idx (eb_message_id),
CONSTRAINT msg FOREIGN KEY (eb_message_id) REFERENCES eb_messages (id) ON DELETE CASCADE ON UPDATE CASCADE
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS eb_settings;
CREATE TABLE eb_settings (
id int(11) NOT NULL,
eb_instances_number int(11) DEFAULT ‘5’,
eb_max_trial_number int(11) DEFAULT ‘2’,
eb_show_instances_consoles int(11) DEFAULT ‘0’,
eb_max_pending_emails int(11) DEFAULT ‘30’,
PRIMARY KEY (id)
) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS eb_smtps;
CREATE TABLE eb_smtps (
id int(11) NOT NULL,
eb_host varchar(245) DEFAULT NULL,
eb_port int(11) DEFAULT ‘25’,
eb_required_authentication int(11) DEFAULT ‘0’,
eb_username varchar(245) DEFAULT NULL,
eb_password varchar(245) DEFAULT NULL,
eb_number_of_use int(11) DEFAULT ‘0’,
eb_enableSSL int(11) DEFAULT ‘0’,
is_active int(11) DEFAULT NULL,
eb_title varchar(245) DEFAULT NULL,
eb_next_use_date datetime DEFAULT NULL,
eb_system_note text,
PRIMARY KEY (id)
) DEFAULT CHARSET=utf8;
Let’s write the code now
Now right click on frm_startup.vb and choose View Code.
image025.jpgWe organize the code by regions
image026.jpgWe will create the timer sub,
From the interface of our form frm_startup, double-click on the timer
image027.jpgWe will treat the exception, write try and press Enter
image028.jpgWe will write some functions that we will use frequently, so we will add and create a new folder we call LIBRARY and we add a class we call it eb_library, so let’s do it.
1—Right click on the project name and -> Add - > New Folder
image029.jpg2—Right click on the folder Library -> Add -> Class
image030.jpgRename the class to eb_library.vb
image031.jpg3—Click on Add button.
Like we did on the form frm_startup.vb, we will add the regions.
image032.jpgWe add the first function print_out_error. This function will display errors on the console.
image033.jpgWe will add a new module to declare the global variables, right click on the folder MAIN -> Add -> Module
image034.jpgRename the file to dec.vb
image035.jpgClick on button Add.
We declare a global variable library.
image036.jpgNow, back to the frm_startup.vb.
Add a line in the catch part to print out the details in the console.
image037.jpgWe create a new function where we will run all the scripts and processing.
image038.jpgNow, we call the function run_scripts in the timer sub.
image039.jpgNow, we will back to the database and create the connection with the MySQL server, we will create a new class and we will write some code, so let’s create our class.
1—Right click on the project -> Add - > New Folder
2—Rename the folder to CONNECT.
We create a new class now, right click on the connect folder -> Add -> Class
image040.jpgI won’t explain all the functions in the class eb_connect, when we call a fucntion I will explain the parameters and the result expected, I believe they are not hard to understand at all, they are very usefull.
Now we have to add a reference to be able to connect the MySQL database, the driver is called MySql.Data.dll , you can download the MySQL Connector 6.7.4 or later from here http://dev.mysql.com/downloads/connector/net/.
We add the reference MySql.Data
1—Right click on the project name - > Add Reference.
image041.jpgThis screen will pop up , click on Browse
image042.jpgLocate the file MySql.Data.dll
image043.jpgFinally click on button Add.
Back to class eb_connect and import some package
image044.jpgWe will add another class, we will call it eb_connection_parameters, we add it in the folder CONNECT,
Right click on the folder CONNECT -> Add - > class
image045.jpgWe will create a simple encryption functions in the class eb_library.vb, we will use this functions
‘’’
‘’’ decrypt a string
‘’’
‘’’ Input>
‘’’
‘’’
Public Function decrypt(ByVal Input As String, key As String) As String
Try
Dim buffer() As Byte = Convert.FromBase64String(Input)
Dim des As TripleDESCryptoServiceProvider = New TripleDESCrypto
ServiceProvider
Dim Vector() As Byte = {&H12, &H44, &H16, &HEE, &H88, &H15, &HDD, &H41}
‘
‘Perfom key
‘***********
des.Key = Me.get_encryption_Key(key)
des.IV = Vector
Return Encoding.UTF8.GetString(des.CreateDecryptor().TransformFinalBlock(buffer, 0, buffer.Length()))
Catch ex As Exception
Return
End Try
End Function
‘’’
‘’’ Encrypt a string
‘’’
‘’’ Input>
‘’’
‘’’