Tuesday, August 4, 2015
Send E-mail VB.net
How send e-mails using VB.net?
Hey guys. Today I will do a very simple tutorial to send e-mails, let´s go!
First open your Visual Studio and Create a New Project using Visual Basic. Rename it if you want.
So, in your Form add three TextBox ok? One it will be to text the message (Body), other to write the subject (Subject) and finally the destiny (To). Add also a Button with the text “Send”. Double-Click in the button.
Send E-mail Form
Try
Dim Mail AsNew MailMessage
Mail.Subject = Subject.Text
Mail.To.Add(To.Text)
Mail.From = New MailAddress("your_email@hotmail.com")
Mail.Body = Body.Text
Dim SMTP AsNew SmtpClient("smtp.live.com") 'server of Outlook, Live and Hotmail accounts
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("your_email@hotmail.com", "your_password")
SMTP.Port = 587 ‘port for Microsoft accounts
SMTP.Send(Mail)
MsgBox("Message has been sent with sucess", vbOKOnly + vbInformation, "YUPII!") ‘Finally show a MessageBox
Catch ex As Exception
MsgBox(ex.Message, vbOK + vbCritical, "Error")
End Try
Add a Login Form
Now I will teach you using a Login Form to send e-mails. It´s very easy. First you will add a new form. I will use a LoginForm to make it easier but you can use a normal form. Right-Click in your Project < Add < Windows Form < LoginForm. Rename it if you want. Now Double-Click in OK button. If you use a normal Form use have to add one Textbox, a MeskedTextBox, two buttons (OK & Cancel or Close).
Private Sub OK_Click(ByValsender As System.Object, ByVal e AsSystem.EventArgs) HandlesOK.Click
IfUsernameTextBox.Text = "" Then
MsgBox("Invalid e-mail")
Else
If PasswordTextBox.Text = ""Then
MsgBox("Invalid Password")
Else
Form1.Show()
Me.Close()
End If
EndIf
EndSub
Now you just have to change the StartUp Form from Form1 to LoginForm1. I hope you liked. Any questions send e-mail for antivirusdownloadfullversion@outlook.com
Labels:
VB.net
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment