[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 768
  • Last Modified:

VB.Net 2005 SMTP problem

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
PTBNA
Asked:
PTBNA
  • 2
1 Solution
 
HillwaaaCommented:
Hi PTBNA,

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

Cheers,
Hillwaaa
0
 
Éric MoreauSenior .Net ConsultantCommented:
can it be your antivirus application?
0
 
PTBNAAuthor Commented:
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
 
PTBNAAuthor Commented:
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

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now