[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

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
0
KaiserSose
Asked:
KaiserSose
  • 3
  • 2
2 Solutions
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now