Solved

VB.Net 2005 SMTP problem

Posted on 2006-11-29
4
717 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

18 Experts available now in Live!

Get 1:1 Help Now