I have a datagrid and when populated I would like to loop through the rows and
add the rows to a email below is how I setup the datagrids
'Sets up the DGVInvItems DGV
Public Sub setupRMAItems()
DGVRMAItems.DataSource = GetRMAItems()
DGVRMAItems.Columns("DetailID").Visible = False
DGVRMAItems.Columns("PCode").Width = 150
DGVRMAItems.Columns("PDescription").HeaderText = "Descripton"
DGVRMAItems.Columns("PDescription").Width = 300
DGVRMAItems.Columns("Qty").HeaderText = "Qty Invoiced"
End Sub
'Gets all lines for the selected invoice
Public Function GetRMAItems() As DataView
Dim SelectQry = "SELECT detailID,PCode,PDescription,Qty from TBLRMA_Detail WHERE RMANumber='" & Me.LBRMANumber.Text & "'"
Dim ReturnItems As New DataSet
Dim TableView As DataView
Try
Dim SampleCommand As New SqlCommand()
Dim SampleDataAdapter = New SqlDataAdapter()
SampleCommand.CommandText = SelectQry
SampleCommand.Connection = Connection
SampleDataAdapter.SelectCommand = SampleCommand
SampleDataAdapter.Fill(ReturnItems)
TableView = ReturnItems.Tables(0).DefaultView
Catch ex As Exception
Throw ex
End Try
Return TableView
End Function
here is how I send my email I would like help with the email body where I would like
all the datagrid rows to be shown.
_NewCompEmailAddress = Me.txtemail.Text
Try
Dim SmtpServer As New SmtpClient()
Dim mail As New System.Net.Mail.MailMessage()
SmtpServer.Credentials = New System.Net.NetworkCredential(_SMTPusername, _SMTPpassword)
SmtpServer.Port = _SMTPport
SmtpServer.Host = _SMTPmailserver
mail = New System.Net.Mail.MailMessage()
mail.From = New MailAddress("RMA@Leyland.co.uk", " RMA")
mail.To.Add(_NewCompEmailAddress)
mail.Subject = "New return authorisation case - " & Me.LBRMANumber.Text
mail.Body = ?????? Datagridview rows...?????
'return authorisation number
SmtpServer.Send(mail)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
any help would be greatfully received.