Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.Net 2005 SMTP problem

Posted on 2006-11-29
4
Medium Priority
?
763 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 70

Accepted Solution

by:
Éric Moreau earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

916 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