Solved

VB.Net 2005 SMTP problem

Posted on 2006-11-29
4
705 Views
Last Modified: 2012-06-27
I can send mail just fine, except for one small problem that I haven't seen any solutions to.

Here's my code:

Dim mailMessage As New MailMessage(New MailAddress("TrustCallCenter@pioneertrustbank.com"), New MailAddress(ToEMail & "@pioneertrustbank.com"))
        With mailMessage
            .BodyEncoding = System.Text.Encoding.Default
            .Subject = "Call Center Callback Request"

            .Body = EMailBody.ToString
            .Priority = MailPriority.High
            .IsBodyHtml = False

            'Dim smptpermission As New SmtpPermission(Security.Permissions.PermissionState.Unrestricted)
            'smptpermission.Assert()

            Dim smtpMail As New SmtpClient
            smtpMail.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network

            smtpMail.Host = "mail.ptbna.com"
            smtpMail.Send(mailMessage)

            mailMessage = Nothing
            smtpMail = Nothing

The problem:  The mail does not actually get sent until after the program closes.  

How do I get the mail message to be sent immedately instead of waiting until the program closes?????

Thanks
Chuck
0
Comment
Question by:PTBNA
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Hillwaaa
ID: 18041598
Hi PTBNA,

What happens if you try the SendAsync method (instead of Send)?

Cheers,
Hillwaaa
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 18042167
can it be your antivirus application?
0
 

Author Comment

by:PTBNA
ID: 18042359
Tried that not really understanding the difference, but there wasn't any difference.

The only thing left to try is building it and running from a cmd prompt.
0
 

Author Comment

by:PTBNA
ID: 18042402
Sometimes I hate Anit-Virus.  Because we were using SMTP for mail, Symantec blocks it until the program closes, and then checks the mail and releases it.

Thanks for the hint.

Chuck
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now