HI
I need to send data from my mssql table to my client by email...
Currently I can send one by one items.(more than 200 items)
Private Sub SendEmail()
Dim body As String = Me.PopulateBody
Me.SendHtmlFormattedEmail(Session("email"), ".", body)
Session.Remove("email")
End Sub
Private Sub SendHtmlFormattedEmail(ByVal recepientEmail As String, ByVal subject As String, ByVal body As String)
Dim client As New SmtpClient()
Dim mail As New MailMessage()
mail.Body = body
mail.[To].Add(recepientEmail)
mail.Subject = "THE STOCK LOG"
mail.IsBodyHtml = True
client.Send(mail)
End Sub
Private Function PopulateBody() As String
Dim data As SqlDataReader
cmd = New SqlCommand
cmd.Connection = conn
cmd.CommandText = ("Select itemid, itemdes, balqty from tbl_stock_bal where itemid ='" & Me.txttItemID.Text & "'")
cmd.CommandType = CommandType.Text
conn.Open()
data = cmd.ExecuteReader
If (data.Read) Then
Dim itemid As String = data.Item("itemid")
Dim itemdes As String = data.Item("itemdes")
Dim qty As String = data.Item("balqty")
Dim body As String = String.Empty
'Dim mail As New MailMessage()
Dim reader As StreamReader = New StreamReader(Server.MapPath("Materials.html"))
body = reader.ReadToEnd
body = body.Replace("{Date}", Date.Now)
body = body.Replace("{itemid}", itemid)
body = body.Replace("{itemdes}", itemdes)
body = body.Replace("{balqty}", qty)
Session("email") = "maideen5@hotmail.com"
Return body
End If
cmd = Nothing
conn.Close()
End Function
Below is my code. It is working fine but one by one
pls advice me...