Datagrid email problem

Joined
Mar 2, 2008
Messages
1
Reaction score
0
Please help!!!

i am greating a nested datagrd and i want to email the content of each row, including the nested datagrid (as individual emails)to an email address

i keep getting multiple emails per row. please tell me what i am doing wrong

Code:
 Private Sub DataGrid2_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid2.ItemDataBound
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            Dim gv As DataGrid = DirectCast(e.Item.FindControl("datagrid3"), DataGrid)
            Dim intRow As Integer = 0
            Dim strName As String = ""
            Dim strPercent As String = ""
            Dim dblTotal As Double = 0
            Dim dblPercent As Double = 0
            '
            ' Number of rows in the DataGrid
            '
            Dim intRows As Integer = DataGrid2.Items.Count - 1
            'Dim blnChecked As Boolean = False
            '
            ' DataGrid rows are really DataGridItems.
            '
            Dim GridItem As DataGridItem
            For intRow = 0 To intRows
                '
                ' Get the grid row.
                '
                Dim Intid = DataGrid2.Items(intRow).Cells(0).Text

                Dim ds2 As New DataSet
                Dim str
                ' str = ds2.Tables(0).Rows(0).Item("email")


                Dim cnn2 As New SqlConnection("Data Source=212.241.251.122,5000;Initial Catalog=bj;User ID=bjobs;Password=bjobs")
                Dim cmd2 As New SqlDataAdapter("SELECT top 10  email,vacancyID FROM jbe_match WHERE userID = '" & Intid & "'", cnn2)
                'Create and fill the DataSet.

                cmd2.Fill(ds2, "jbe_match")
                gv.DataSource = ds2
                gv.DataBind()


                Dim SB As New StringBuilder
            Dim SW As New StringWriter(SB)
            Dim htmlTW As New HtmlTextWriter(SW)
            gv.RenderControl(htmlTW)

            Dim dataGridHTML As String = SB.ToString()


            'Render DataGrid output as Html

            ' gv.RenderControl(hw)
            ' Dim dataGridHTML As String = hw.ToString()
            Dim Mail As New MailMessage
            Mail.From = "[email protected]"
            Mail.To = "[email protected]"
            Mail.Cc = ""
            Mail.Bcc = ""
            Mail.Subject = "Requested Eligibility Change - " & e.Item.Cells(1).Text
            Mail.BodyFormat = MailFormat.Html
            Mail.Body = dataGridHTML
            Mail.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
            Mail.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "support@britishjob"
            Mail.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "letmein"


            SmtpMail.SmtpServer = "22.24.17.10"
            SmtpMail.Send(Mail)
            Next

        End If
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top