devnewbee
asked on
How can I scrape a rendered .aspx page and email it?
I wish to scrape whats rendered ona results page and email it. This includes results from a form view, textbox controls, dynamically generated tables etc. I basically want to do a screenshot or send the infiormation that is rendered as a text file.
I can scrape the page thus far, but not the rendered data.
I can scrape the page thus far, but not the rendered data.
Read this:
http://www.csharpfriends.com/Articles/getTip.aspx?articleID=210
This example is asking you for an input url but you can change it to take the current page. The code puts the whole page in the string variable which you can then email.
http://www.csharpfriends.com/Articles/getTip.aspx?articleID=210
This example is asking you for an input url but you can change it to take the current page. The code puts the whole page in the string variable which you can then email.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here is my code for the finish button on this wizard. I get this to work, but only scrapes the page and not the control values on the final step of the wizard.
protected void psWizard_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
{
MailMessage mail = new MailMessage();
mail.To = "test344@gmail.com";
mail.From = "do-not-reply@gmail.com";
mail.Subject = "this is a test email.";
string url = "http://test.geopac.com/screen/";
mail.Body = HttpContent(url);
mail.BodyFormat = MailFormat.Html;
mail.UrlContentBase = url;
SmtpMail.SmtpServer = "relay.geopac.com";
SmtpMail.Send(mail);
}
dsInsert.Insert();
Session["MyInsert"] = true;
}
private string HttpContent(string url)
{
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
return result;
Response.Redirect("~/confirmation.aspx");
}
}
ASKER
J_s_kelley: I cane use the code above, but how do I call for it in the mail.body code of my mail code?
You cant call it you have to do it in the Render method of the page.
ASKER
Ok, so what happens is my user go through a wizard and the final page of the wizard display a results page based on some answers to dropdown etc on the page prior. I just want to send that results information in an email once the user enters their email address in a textbox.
If I actually go to file and use save as (.txt) I see all of the results page formatted in a nice format (not real source). This is kind of what I am looking for in that I want the user to either see a text file, and html file or a .pdf snapshot of the page as rendered once they click the finish button.
If I actually go to file and use save as (.txt) I see all of the results page formatted in a nice format (not real source). This is kind of what I am looking for in that I want the user to either see a text file, and html file or a .pdf snapshot of the page as rendered once they click the finish button.
ASKER
Thanks urir.
Generate a PDF or an MDI and attach it to the email.
regards
Dinesh