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
306 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 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

705 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