Last active
December 14, 2015 15:49
-
-
Save facebookegypt/5110622 to your computer and use it in GitHub Desktop.
Send E-mail with vb.Net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'The Mail Class we use to send e-mails | |
Imports System.Net.Mail | |
'The form name : SendFrm | |
Public Class SendFrm | |
Dim SmtpSvr As New Net.Mail.SmtpClient() | |
Dim E_mail As New Net.Mail.MailMessage() | |
Dim UsrNm, Pwd, Srve As String | |
Dim Int_port As Integer | |
Private Sub SendFrm_Load (ByVal sender As System.Object, _ | |
ByVal e As System.EventArgs) Handles MyBase.Load | |
'I'm using Gmail.com | |
UsrNm = ("[email protected]") | |
'My 2-Step Verfication Password (Link) coz | |
'I enable this method, if not then your regular Password. | |
Pwd = ("Your_Password") | |
Srve = ("pop.gmail.com") | |
Intport = 587 | |
End Sub | |
Private Sub Label11_Click(ByVal sender As System.Object, _ | |
ByVal e As System.EventArgs) Handles Label11.Click | |
'I'm using Label11 to send : Name (Send) | |
SmtpSvr.UseDefaultCredentials = False | |
SmtpSvr.Credentials = New Net.NetworkCredential(UsrNmt.ToString, Pwd.ToString) | |
SmtpSvr.Port = Intport | |
SmtpSvr.Host = Srve.ToString | |
E_mail = New MailMessage() | |
E_mail.From = New MailAddress(UsrNm.ToString, "Whatever_You_Desire", System.Text.Encoding.UTF8) | |
E_mail.IsBodyHtml = False 'Still Working on it. | |
E_mail.Body = ("Hello, This is my first E-mail though My Client") | |
SmtpSvr.EnableSsl = True | |
E_mail.To.Add(TxtFrnd.Text.ToString) 'TextBox Name : TxtFrnd | |
E_mail.Subject = (TxtSub.Text.ToString) 'TextBox Name : TxtSub | |
Cursor = Cursors.WaitCursor | |
SmtpSvr.Send(E_mail) | |
MsgBox("mail sent") | |
Cursor = Cursors.Default | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment