Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you don't need to redirect the page, after you render the contents of the page (from your code sample, it doesn't look like you need to), then you may want to use a Response.Filter.</p> <p>Off the top of my head, it would look something like:</p> <pre><code>protected void Page_Load(object sender, System.EventArgs e) { Response.Filter = new SmtpFilter(Response.Filter); } </code></pre> <p>The SmtpFilter class, is just a class that inherits from the Stream object.</p> <p>The main method will be the Write method. Here is some code off the top of my head to Override the Write(...) method, send the Smtp mail, and continue on processing.</p> <pre><code> public override void Write(byte[] buffer, int offset, int count) { // get the html string content= System.Text.Encoding.UTF8.GetString(buffer, offset, count); MailMessage mail = new MailMessage(); mail.From = new MailAddress("test@test.com"); mail.To.Add("steve@test.com"); mail.IsBodyHtml = true; mail.Subject = "Test"; mail.Body = content; SmtpClient smtp = new SmtpClient("1111"); smtp.Send(mail); buffer = System.Text.Encoding.UTF8.GetBytes(HTML); this.Base.Write(buffer, 0, buffer.Length); } </code></pre> <p>If you need more help on Response.Filters, you may want to google it. The first article I found was in VB.NET, but still helpful:</p> <p><a href="http://aspnetlibrary.com/articledetails.aspx?article=Use-Response.Filter-to-intercept-your-HTML" rel="nofollow noreferrer">http://aspnetlibrary.com/articledetails.aspx?article=Use-Response.Filter-to-intercept-your-HTML</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload