Part of an application I am making, I wish to make a one button click email sender which will send me a copy of what the user has put in a text box. I don't want them to mess around with having to fill out forms of the email to send it to.
Any Ideas on how to impliment this? (I'm using Visual Basic)
Imports System.Net.Mail
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Set the caption bar text of the form.
Me.Text = "tutorialspoint.com"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential("username@gmail.com", "password")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress(txtFrom.Text)
e_mail.To.Add(txtTo.Text)
e_mail.Subject = "Email Sending"
e_mail.IsBodyHtml = False
e_mail.Body = txtMessage.Text
Smtp_Server.Send(e_mail)
MsgBox("Mail Sent")
Catch error_t As Exception
MsgBox(error_t.ToString)
End Try
End Sub
source: http://www.tutorialspoint.com/vb.net/vb.net_send_email.htm
Replace Smtp_Server.credentials with your own gmail email and password.
There's also a lot of tutorials on YouTube that you can check out if you search for "visual basic email sender".