Link to home
Start Free TrialLog in
Avatar of DJ P
DJ PFlag for United States of America

asked on

VB.net sending emails based on new records

Hello experts. I have a vb.net form that connects to a hosted MySQL database which contains a table for visitor data. As a secondary check (which I won't get into the reasons why) what I would ultimately like to do is hit a button that checks for any new records that were added to the table and send out an email showing which records were added. I created a form that connects to the database and have the datagridview showing all the records just to verify I am connecting with no issues. Its the code behind the button which I described above that I have zero clue how to accomplish. Below is what I have so far. Any help for a newbie learning to code which be most helpful.

App Configure Tab:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>

  <connectionStrings>
    <add name="dbx" connectionString="server=xxxxxx;user id=xxxxx=;Password=xxxxxxxxx;database=XXXXXXX" providerName="MySqlData.MySqlClient" />
  </connectionStrings>
</configuration>

Form:

Imports System.Configuration
Imports MySql.Data
Imports MySql.Data.MySqlClient


Public Class Form2
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        DataGridView1.DataSource = GetVisitorsList()
    End Sub

    Private Function GetVisitorsList() As DataTable
        Dim dtVisitors As New DataTable
        Dim connstring As String = ConfigurationManager.ConnectionStrings("dbx").ConnectionString

        Using conn As New MySqlConnection(connstring)
            Using cmd As New MySqlCommand("Select FirstName, LastName, Company, Country, USCitizen, Citizenship, DateSubmitted From visitors order by DateSubmitted ASC", conn)


                conn.Open()

                Dim reader As MySqlDataReader = cmd.ExecuteReader()
                dtVisitors.Load(reader)


            End Using

        End Using

        Return dtVisitors



    End Function
End Class
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial