PTBNA
asked on
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("TrustCallCent er@pioneer trustbank. com"), New MailAddress(ToEMail & "@pioneertrustbank.com"))
With mailMessage
.BodyEncoding = System.Text.Encoding.Defau lt
.Subject = "Call Center Callback Request"
.Body = EMailBody.ToString
.Priority = MailPriority.High
.IsBodyHtml = False
'Dim smptpermission As New SmtpPermission(Security.Pe rmissions. Permission State.Unre stricted)
'smptpermission.Assert()
Dim smtpMail As New SmtpClient
smtpMail.DeliveryMethod = Net.Mail.SmtpDeliveryMetho d.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
Here's my code:
Dim mailMessage As New MailMessage(New MailAddress("TrustCallCent
With mailMessage
.BodyEncoding = System.Text.Encoding.Defau
.Subject = "Call Center Callback Request"
.Body = EMailBody.ToString
.Priority = MailPriority.High
.IsBodyHtml = False
'Dim smptpermission As New SmtpPermission(Security.Pe
'smptpermission.Assert()
Dim smtpMail As New SmtpClient
smtpMail.DeliveryMethod = Net.Mail.SmtpDeliveryMetho
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
The only thing left to try is building it and running from a cmd prompt.
ASKER
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
Thanks for the hint.
Chuck
What happens if you try the SendAsync method (instead of Send)?
Cheers,
Hillwaaa