Imports
System.Net
Public
Class
Form1
Dim
mail
As
New
Mail.MailMessage()
Dim
SmtpServer
As
New
Mail.SmtpClient
Private
Sub
Button1_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button1.Click
Try
If
My.Computer.Network.IsAvailable =
True
Then
SmtpServer.Credentials =
New
Net.NetworkCredential(
"vase uzivatelske meno (mail)"
,
"heslo k mailu"
)
SmtpServer.Port = 587
SmtpServer.Host =
"smtp server , napriklad smtp.gmail.com"
SmtpServer.EnableSsl =
True
mail.
To
.Add(
"dorucitel mailu"
)
mail.From =
New
Net.Mail.MailAddress(
"od koho prisiel mail - vas mail"
)
mail.Subject =
"predmet mailu"
mail.Priority = Net.Mail.MailPriority.High
mail.Body =
"text v maili"
SmtpServer.Send(mail)
ElseIf
My.Computer.Network.IsAvailable =
False
Then
MsgBox(
"chyba , nieste pripojeny k sieti internet "
, MsgBoxStyle.Critical,
"odosielanie mailu"
)
End
If
Catch
ex
As
Exception
MsgBox(
"chyba , zadali ste nespravne udaje"
+ vbNewLine + ex.Message, MsgBoxStyle.Critical,
"odosielanie mailu"
)
End
Try
End
Sub
End
Class