Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am using the following Private Sub of a class to send e-mail. My company uses Norton to scan outgoing e-mails. This function, in VB.NET 2003, used System.Web.Mail, from a Windows Application, and sent the e-mails immediately. Now, using it in VB.NET 2005 and System.Net.Mail, the e-mails do not get sent until I close the program to which this class belongs (being run in both Debug configuration via the IDE and the compiled .EXE). It's very strange. I have no idea how or why the e-mails would be caching somewhere until the program is closed. I know this is happening, because after I close the program, Norton lights up the System Tray like fireworks, for each e-mail being sent.

 


Private Sub SendInvite(ByVal Subject As String, ByVal Body As String, ByVal SendTo As String, _
ByVal Link As String, ByVal Incentive As Integer, ByVal TimeText As String)
       Try
           Dim mailMessage As System.Net.Mail.MailMessage
           Dim mailFrom As System.Net.Mail.MailAddress
           Dim mailTo As System.Net.Mail.MailAddress
           Dim mailSMTP As System.Net.Mail.SmtpClient

           Subject = Replace(Subject, "<SNIP>", TimeText)

           Body = Replace(Body, "<Link>", Space(5) & Link)
           Body = Replace(Body, "<Incentive>", Incentive.ToString)
           Body = Replace(Body, "<TimeText>", TimeText)

           mailFrom = New System.Net.Mail.MailAddress("<SNIP>", "<SNIP>")
           mailTo = New System.Net.Mail.MailAddress(SendTo)
           mailMessage = New System.Net.Mail.MailMessage(mailFrom, mailTo)
           mailMessage.Subject = Subject
           mailMessage.BodyEncoding = System.Text.Encoding.UTF8
           mailMessage.Body = Body

           mailSMTP = New System.Net.Mail.SmtpClient(sSmtpServer)
           mailSMTP.Send(mailMessage)

       Catch ex As Exception
           Throw (ex)
       End Try
   End Sub

 

Variable sSmtpServer is a Private class-level variable assigned by a Public Property of the class.

  • Administrators
Posted

Try turning of Norton and running the test again, does it still wait for the app to exit or are the mails sent straight away?

 

Only mentioning this as I've encountered problems in the past with this kind of thing and it turned out to be the AV product.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...