Send an aspx page as MailMessage.Body

I have sent mail many times so I know how to construct the MailMessage and send it.  I want to email a very detailed report of stuff pulled from a database. I want to have page A have a textbox and button where you enter the users email and click go.   Piece of cake right?  Well, I'd like to avoid having one giant body string that I have to append 500 small strings and variables together to create.

I would love it if it is possible to do something like:

SmtpMail.body = pageb.aspx

The page would be fully working if you navigate to it, and do all the necessary information calculation.  Is this even possible?  

Thanks for looking

dave
LVL 2
KaiserSoseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Razzie_Commented:
What does page b contain? I mean, do you want everything including page b's html code? does it contain the stuff from the database and do you want to send that? If so, what kind of data are we talking about? Is it xml, html, simple strings, etc.

Regards,

Razzie
0
123654789987Commented:
Instead of sending it as the body u can try sending the aspx page as an attachment in the mailMessage
0
KaiserSoseAuthor Commented:
An attachment wouldn't be too bad, but I don't think sending an aspx page is the best file format.  Actually, now that you mention it, an attachment might be the best way to go. Is this still possible?   What I want is an html formatted report.  So it would basically be exactly like you navigated to  whatever.com/pageb.aspx, but it would probably have to be sent as .html and not .aspx because the user will absolutely not have connectivity to the db.   Page b contains a bunch of code behind stuff that pulls many values from a db and formats the report.

Thanks for the help

dave
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

KaiserSoseAuthor Commented:
Oh,  page b doesn't have any super complex values, just alot of billing data.  The report would basically just be tables with headers and values.
0
Razzie_Commented:
Well if the page contains codebehind, I wouldn't go for the attachement way, since that basically means that you can see code between the data, I guess you don't want that.

If you really want the output of the website, the same as you'd see in the browser, why not send a httprequest to the page? It's not hard to request page b with post variables that would normally come from page a too. If you read the contents of the stream that returns from httprequest, you'll have pure html that you can add to the mailmessage body without any further code.

From the sound of how you describe the situation, this should all be possible, if you need further info let me know.

HTH,

Razzie
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KaiserSoseAuthor Commented:
I decided not to send the report by email, the people reading the report preferred to see it online.  Thank you both for helping.

dave
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.