Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 510843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:09:19+00:00 2026-05-13T07:09:19+00:00

I’m making an email sending program and still I don’t know how to check

  • 0

I’m making an email sending program and still I don’t know how to check if the mail was really sent or not, because sometimes the program will have no error messages but the mail was not actually sent. Is there any other way on how to deal with this except for making use of try catch?

Here is my code:

Try
  mail.From = New MailAddress(TextBox2.Text)
  mail.To.Add(New MailAddress(TextBox1.Text))
  mail.Subject = TextBox4.Text
  mail.Body = TextBox4.Text
  mail.IsBodyHtml = True
  Dim client As SmtpClient = New SmtpClient("smtp.gmail.com", 587)
  If TextBox2.Text.Contains("@gmail.com") Then
    client.EnableSsl = True
    client.Credentials = New System.Net.NetworkCredential(TextBox2.Text, TextBox3.Text)
    Try
      client.Send(mail)
    Catch ex As Exception
      MessageBox.Show("Sending email failed. Please Try again")
    End Try
  End If
Catch
  MsgBox("Please input the correct value!")
End Try
ProgressBar1.Value = 100
clear()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:09:19+00:00Added an answer on May 13, 2026 at 7:09 am

    I would typically use try/catch for this sort of thing.

    Instead of catching a Generic Exception you can catch SmtpException and SmtpFailedRecipientsException‘s.

    SmtpException is thrown when a connection could not be made or operation timed out. SmtpFailedRecipientsException is thrown if The message could not be delivered to one or more of the recipients.

    Converted MSDN Code

    Try
        client.Send(message)
    Catch ex As SmtpFailedRecipientsException
        For i As Integer = 0 To ex.InnerExceptions.Length - 1
            Dim status As SmtpStatusCode = ex.InnerExceptions(i).StatusCode
            If status = SmtpStatusCode.MailboxBusy OrElse status = SmtpStatusCode.MailboxUnavailable Then
                Console.WriteLine("Delivery failed - retrying in 5 seconds.")
                System.Threading.Thread.Sleep(5000)
                client.Send(message)
            Else
                Console.WriteLine("Failed to deliver message to {0}", ex.InnerExceptions(i).FailedRecipient)
           End If
        Next
    Catch ex As Exception
        Console.WriteLine("Exception caught in RetryIfBusy(): {0}", ex.ToString())
    End Try
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm making a simple page using Google Maps API 3. My first. One marker
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.