Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 11th, 2006, 12:23 AM
Authorized User
 
Join Date: Jan 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default In my VS2003 project I send mail and it sends 7-8

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("c onnectionString"))

        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 = "[email protected]" '' this is the From Address

                    newMail.To = "[email protected]" '' this is TO Address

                    'newMail.Cc = "[email protected]" '' 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\Prod uct_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", "[email protected]")


                    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
 
Old April 13th, 2006, 01:44 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Quote:
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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Send mail and attachments with PHP mail function Lofa Beginning PHP 1 June 2nd, 2008 03:24 PM
send mail chavakoti BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 September 4th, 2007 05:03 AM
How to send mail Jolley_tolson PHP How-To 0 August 13th, 2007 03:38 AM
Cannot send mail rajanikrishna JSP Basics 3 March 17th, 2006 01:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.