Hello.

When I use the code below to send an e-mail from my form, the mail is not sent before the program is closed...

Anybody have any idea why this is so?!

Code:
        'create the mail message
        Dim mail As New MailMessage

        'set the addresses
        mail.From = New MailAddress("[email protected]")
        mail.To.Add("[email protected]")

        'set the content
        mail.Subject = "Mail Subject here."
        mail.Body = "Mail body here."
        mail.IsBodyHtml = False

        'send the message
        Dim smtp As New SmtpClient("YOUR SMTP SERVER")
        smtp.Credentials = New System.Net.NetworkCredential("Username", "Password")

        Try
            smtp.Send(mail)

        Finally
            mail.Dispose()
            smtp = Nothing

        End Try