VB.Net, Symantec and SMTP e-mail
Posted on 2006-12-01
We are sending e-mail within a vb app. But symantec blocks the e-mail until the program exits, which really is a pain.
We worked around the problem by disabeling the "Internet E-Mail auto-protect". With that disabled, the mail goes out immediately, otherwise, they are held in "limbo" until the program ends and then any e-mails sent are finally passed on.
Here's the code I'm using:
Dim stringFrom As String = ""
ToEMail = mydata.GetOfficerEMail(Convert.ToInt32(OfficerComboBox.SelectedValue))
EMailBody = New StringBuilder
EMailBody.Append("Call Back request from: ")
EMailBody.Append(CallerFirstNameTextBox.Text & " " & CallerLastNameTextBox.Text & vbCrLf)
EMailBody.Append(CallerPhoneNumberTextBox.Text & vbCrLf & vbCrLf)
If NotationTextBox.Text.Trim = "" Then
'TRY TO get the last notation available. If none, then just send the request.
EMailBody.Append(vbCrLf & vbCrLf & "********* No Notation Entered********" & vbCrLf)
'there is text in the notation, send it.
EMailBody.Append(vbCrLf & vbCrLf & NotationTextBox.Text & vbCrLf)
System.Windows.Forms.TextBox.CheckForIllegalCrossThreadCalls = False
System.Windows.Forms.CheckBox.CheckForIllegalCrossThreadCalls = False
System.Windows.Forms.ListBox.CheckForIllegalCrossThreadCalls = False
Dim t As New Thread(AddressOf MailThread)
Private Sub MailThread()
Dim mailMessage As New MailMessage(New MailAddress("TrustCallCenter@pioneertrustbank.com"), New MailAddress(ToEMail & "@pioneertrustbank.com"))
.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)
Dim smtpMail As New SmtpClient
smtpMail.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
smtpMail.Host = "mail.ptbna.com"
mailMessage = Nothing
smtpMail = Nothing
I put it into a thread, hoping the closing of the thread would release the mail, but that didn't make any difference. I really need to remove that code.
Also tried sendAsync, but no difference.
Help, don't like leaving symantec disabled, and have been unable to find a solution to this problem on-line. found one person with the same problem, and their solution un-install Symanted anti-virus.