I have an application that i’m using to send an email that contains an entire table and i don’t know how to get that dynamic data there. I’M SURE i have to use a for loop but i don’t know how to word it to get the rows of data.
Here is what i have so far:
msg.To.Add(selected);//put in custom account info
msg.Subject = "Message Subject";
msg.IsBodyHtml = true;
msg.Body = "<html>"+
"<body>"+
"<center>"+
"<h2>Your entire inventory:</h2>"+
"<table>"+
"<th>Product</th>"+
//for each loop
"<th>Quantity</th>"+
//for each loop
"</body>"+
"</html>";
Let me know if you need any other code.
Personally, I would avoid building HTML using string concatenation. Not only can it make your code awkward, but you also risk accidental mistakes in encoding your output. One alternative is to use LINQ to XML to build your HTML. The code would look something like this: