|
Subject:
|
In my VS2003 project I send mail and it sends 7-8
|
|
Posted By:
|
kenn_rosie
|
Post Date:
|
4/11/2006 12:23:19 AM
|
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
<System.Diagnostics.DebuggerStepThrough()> 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("http://schemas.microsoft.com/cdo/configuration/sendpassword", "Password")
SmtpMail.SmtpServer = ""
SmtpMail.Send(newMail)
End If
End If
End While
myConnection.Close() 'Close the connection
End Sub
|
|
Reply By:
|
jbenson001
|
Reply Date:
|
4/13/2006 1:44:55 PM
|
quote:
"Select LastUpdated, ProductId from products "
you are going to retrive LastUpdate for each row in the table. You need to specify a WHERE clause
|
|