none
Email Program RRS feed

  • Question

  • Hi:

    I found the following vb code for sending an email. It doesn't work. I have also included the error message.

    I don't see how the recipient gets into the code.

    Can someone please give me a hand. Thanks.

    Imports System.Net.Mail
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            Me.Text = "Send Email"
    
        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 = True
                Smtp_Server.Credentials = New Net.NetworkCredential("User@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(txtFrom.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
    
    End Class
    
    

    ***************************************************************************************

    



    Friday, April 3, 2020 4:34 PM

Answers

All replies