Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I convert a table object to a string for an HTML email or insert table object into body of HTML email?

Posted on 2008-10-07
2
Medium Priority
?
310 Views
Last Modified: 2013-11-19
I have a function that returns a table to display what a user has purchased for their receipt.
I am displaying the page when the user completes their order, but I'd also like to email the user a copy of the receipt.
The problem I am facing is the email class I'm using (MailMessage) only accepts a String for the body.
Thus, my originally intended code (myMailMessage.Body = myTable) is unacceptable.

I need to either convert the myTable object into a string or find a way to implement my table into the body of this html email message.
(I'm using VB .NET)
0
Comment
Question by:ManageMobility
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 2000 total points
ID: 22659026
Hello ManageMobility,

This function will render any control to html. In your case you could use: myMailMessage.Body = GetHTMLFromControl(myTable)

Regards,

TimCottee
    Public Function GetHTMLFromControl(ByRef TheControl As Object) As String
        Dim tw As IO.StringWriter = New IO.StringWriter
        Dim hw As Html32TextWriter = New Html32TextWriter(tw)
        TheControl.RenderControl(hw)
        Dim html As String = tw.ToString
        hw = Nothing
        tw = Nothing
        Return html
    End Function

Open in new window

0
 
LVL 2

Author Closing Comment

by:ManageMobility
ID: 31503822
That was the fastest and probably best response I've ever gotten from any IT assistance site. Thank you very much!
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question