Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

How to Write a Bulk Emails Application in Vb.Net and Mysql: Step by Step Fully Working Program
How to Write a Bulk Emails Application in Vb.Net and Mysql: Step by Step Fully Working Program
How to Write a Bulk Emails Application in Vb.Net and Mysql: Step by Step Fully Working Program
Ebook568 pages2 hours

How to Write a Bulk Emails Application in Vb.Net and Mysql: Step by Step Fully Working Program

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Why am I writing this book?

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.
LanguageEnglish
PublisherXlibris AU
Release dateFeb 5, 2014
ISBN9781493132881
How to Write a Bulk Emails Application in Vb.Net and Mysql: Step by Step Fully Working Program
Author

Lotfi Ferchichi

Author Biography Coming Up Soon

Related to How to Write a Bulk Emails Application in Vb.Net and Mysql

Related ebooks

Teaching Methods & Materials For You

View More

Related articles

Reviews for How to Write a Bulk Emails Application in Vb.Net and Mysql

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    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.jpg

    Click on ok, you will have your project ready

    image002.jpg

    Let’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.jpg

    Note: if you are not seeing the properties window, please go to menu View -> Properties Window

    image004.jpg

    Save the project, click on the button save

    image005.jpg

    Click 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.jpg

    Now, 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.jpg

    I’m going to add a statusStrip.

    image009.jpg

    And also, I will add a TabControl.

    image010.jpg

    Set the dock to fill

    image011.jpg

    We remove the second Tab, so go again the properties window and click on Tab Pages

    image012.jpg

    Select the TabPage2 and click on remove

    image013.jpg

    And rename the first tab to Log

    image014.jpg

    Now click on OK.

    Now we will add a new listview where we will display all logs, from the toolbox, look for listview

    image015.jpg

    Select the listview from the toolbox and add it the form

    image016.jpg

    Now we add the columns, on the properties window click on columns

    image017.jpg

    This dialog will pop up, click on button Add to add the column

    image018.jpg

    Ye should add the following columns

    image019.jpg

    Now we change the view to details, go to properties window and choose view and change it to Details

    image020.jpg

    Now, 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.jpg

    Now we add a timer control, again, go to the toolbox and look for timer

    image022.jpg

    Set the interval to 1000 (1 second)

    image023.jpg

    Installing 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.jpg

    We organize the code by regions

    image026.jpg

    We will create the timer sub,

    From the interface of our form frm_startup, double-click on the timer

    image027.jpg

    We will treat the exception, write try and press Enter

    image028.jpg

    We 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.jpg

    2—Right click on the folder Library -> Add -> Class

    image030.jpg

    Rename the class to eb_library.vb

    image031.jpg

    3—Click on Add button.

    Like we did on the form frm_startup.vb, we will add the regions.

    image032.jpg

    We add the first function print_out_error. This function will display errors on the console.

    image033.jpg

    We will add a new module to declare the global variables, right click on the folder MAIN -> Add -> Module

    image034.jpg

    Rename the file to dec.vb

    image035.jpg

    Click on button Add.

    We declare a global variable library.

    image036.jpg

    Now, back to the frm_startup.vb.

    Add a line in the catch part to print out the details in the console.

    image037.jpg

    We create a new function where we will run all the scripts and processing.

    image038.jpg

    Now, we call the function run_scripts in the timer sub.

    image039.jpg

    Now, 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.jpg

    I 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.jpg

    This screen will pop up , click on Browse

    image042.jpg

    Locate the file MySql.Data.dll

    image043.jpg

    Finally click on button Add.

    Back to class eb_connect and import some package

    image044.jpg

    We 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.jpg

    We 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>

    ‘’’

    ‘’’

    Enjoying the preview?
    Page 1 of 1