Results 1 to 3 of 3

Thread: Send email from dataset rows (Resolved)

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Send email from dataset rows (Resolved)

    I am trying to send emails for records found in my dataset
    VB Code:
    1. Private Sub SendConfirmationEmail_x()
    2.         Dim getZip As String = txtZip.Text
    3.         Dim getRad As Integer = CInt(ddlRadius.SelectedValue)
    4.         Dim myDS As DataSet = GetUE_ZipRadius(getZip, getRad)
    5.         Dim intCountDs As Integer = DataList1.Items.Count
    6.         Dim myDR As DataRow
    7.  
    8.         With myDS.Tables("ZipCodes")
    9.             For Each myDR In myDS.Tables
    10.                 Dim strMailTo As String = myDS.Tables(1).ToString
    11.                 Dim strMailServer As String = "mail.*******.com"
    12.                 Dim strMailFrom As String = "admin@*******.com"
    13.                 Dim strMailSubject As String = "Test Email"
    14.                 Dim strMailMsg As String = "Mail Messege"
    15.  
    16.                 Dim MailObj As New System.Net.Mail.SmtpClient
    17.                 MailObj.Host = strMailServer
    18.                 MailObj.Send( _
    19.                     strMailFrom, _
    20.                     strMailTo, _
    21.                     strMailSubject, _
    22.                     strMailMsg)
    23.             Next
    24.         End With
    25.         myDS.Dispose()
    26.     End Sub
    I am getting Unable to cast object of type 'System.Data.DataTable' to type 'System.Data.DataRow'. and then it highlights this part of the code
    VB Code:
    1. Line 154:        End If
    2. Line 155:        With myDS.Tables("ZipCodes")
    3. Line 156:            [b]For Each myDR In myDS.Tables[/b]
    4. Line 157:                Dim strMailTo As String = myDS.Tables(1).ToString
    5. Line 158:                Dim strMailServer As String = "mail.uncleedsoil.com"
    What am I doing wrong?
    Last edited by FastEddie; Jun 5th, 2006 at 01:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width