Last post Nov 30, 2013 12:52 PM by vetralph
Nov 26, 2008 10:11 AM|polynaux|LINK
I am looping through a datatable and just wonder how
to add the rows I loop through to my email body:
mail.body = "hello"
A datatable with nice borders and colours defined, can this be
just added to the body of an email?
Nov 26, 2008 10:27 AM|tfsmag|LINK
Dim mm As New MailMessage(UsersEmail.Text, ToAddress)
mm.Subject = Subject.Text
mm.Body = Body.Text
mm.IsBodyHtml = True 'set the body of the mail to html, and you can put standard html
'create smtp client to send message
Dim smtp As New SmtpClient
Nov 26, 2008 10:28 AM|tfsmag|LINK
Nov 26, 2008 11:23 AM|polynaux|LINK
Thanks for your reply. I am aware that I can use html. That does not explain how I add (or print) a colection like a datatable.rows or a generic.list to
the email/screen dynamically each time when I loop. How do I add a collection?? Do I.....add it as an object and hope that mail.body can resolve it...likely not.
Nov 26, 2008 11:37 AM|tfsmag|LINK
No, you will need to loop through your collection,datatable, or list and print the table out to a string in html. Row by row. Something like this.
Dim body as string = "<table>"
for each r as datarow in dt.rows
body += "<tr><td>" & r("item1") & "</td></tr>"
body += "</table>"
then your table should be contained in the body string.
Nov 26, 2008 11:50 AM|polynaux|LINK
that sounds good.
I will try it tonight.
Dec 05, 2008 04:49 AM|polynaux|LINK
Nov 28, 2013 02:12 PM|vetralph|LINK
I am fairly new at VB2010 programming. Love it.
Ran accoss this code and tried to use it.
Received the following io error:
at System.Net.Mail.SmtpClient.Send(MailMessage message)</StackTrace><ExceptionString>System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
Can you help?
Nov 30, 2013 12:52 PM|vetralph|LINK
found the problem