Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. In my VS2003 project I send mail and it sends 7-8 times every time I send it?

In my VS2003 project I send mail and it sends 7-8 times every time I send it?

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasecomdockerhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kenn_rosie
    wrote on last edited by
    #1

    In my VS2003 project I send mail and it sends 7-8 times every time I send it? I have the following code in my global.asax code, The problem is the receiver gets 7-8 copies every time i SEND IT? Public Class Global Inherits System.Web.HttpApplication #Region " Component Designer Generated Code " Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Required by the Component Designer Private components As System.ComponentModel.IContainer Private Sub InitializeComponent() components = New System.ComponentModel.Container() End Sub #End Region Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Fires when the application is started '1. Create a connection Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("connectionString")) myConnection.Open() '2. Create the command object, for the query Const strSQL As String = "Select LastUpdated, ProductId from products " Dim objCmd As New SqlCommand(strSQL, myConnection) Dim objDR As SqlDataReader Dim att objDR = objCmd.ExecuteReader() While (objDR.Read) If (Not (objDR("LastUpdated") Is DBNull.Value)) Then If (Date.Compare(objDR("LastUpdated"), Today.Date) = 0) Then Dim newMail As New MailMessage newMail.From = "zzzxyz@msn.com" '' this is the From Address newMail.To = "bill@msn.com" '' this is TO Address 'newMail.Cc = "ken@dtyinc.net" '' this is TO Address newMail.Subject = "Change in Product Rate" newMail.Body = " Dear Ken, " & "Please review attached document for product ID: " & objDR("ProductID") & "Thank you," & "Kenn()" att = New MailAttachment("C:\Inetpub\wwwroot\GrocerToGo\Product_Changed.doc") newMail.Attachments.Add(att) newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "bill@dtyinc.net") newMail.Fields.Add("

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups