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
299 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
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
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…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now