Emailing a dynamically generated aspx page

Discussion in 'ASP .Net' started by Gary Coutts, Apr 20, 2006.

  1. Gary Coutts

    Gary Coutts Guest

    Hi,

    After dynamically generating an aspx page I need to email what is being
    displayed by the browser.

    I have looked at System.Web.Mail but it looks like you have to generate the
    body of the message as one long string.

    Can anyone point me in the right direction.

    I am using VS2003 ASP 1.1.


    Cheers

    Gary Coutts
    Gary Coutts, Apr 20, 2006
    #1
    1. Advertising

  2. Gary Coutts

    q Guest

    Here's a sample... pay close attention to the Render method.

    public bool SendEmail {
    get { return sendEmail; }
    set { sendEmail = value; }
    }

    void btnConfirm_Click(object sender, EventArgs e) {
    try {
    OrderHeaderEntity header = new OrderHeaderEntity(new
    Guid(this.OrderId));
    header.OrderSent = true;
    header.Save( );

    this.SendEmail = true;
    }
    catch (Exception ex) {
    lblErrorMessage.Text = ex.Message;
    }
    }

    protected override void Render(HtmlTextWriter writer) {
    StringBuilder builder = new StringBuilder();
    HtmlTextWriter htmlTextWriter = new HtmlTextWriter(new
    StringWriter(builder));
    base.Render(htmlTextWriter);
    string output = builder.ToString();
    writer.Write(output);
    if (this.SendEmail) {
    this.SendEmail = false;
    SendEmail(output);
    }
    }
    q, Apr 20, 2006
    #2
    1. Advertising

  3. You can email a page by using the WebRequest and MailMessage classes.

    Here are a couple examples:
    http://www.aspalliance.com/stevesmith/articles/dotnetemailwebsite.asp
    http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Gary Coutts" <> wrote in message
    news:%...
    > Hi,
    >
    > After dynamically generating an aspx page I need to email what is being
    > displayed by the browser.
    >
    > I have looked at System.Web.Mail but it looks like you have to generate
    > the body of the message as one long string.
    >
    > Can anyone point me in the right direction.
    >
    > I am using VS2003 ASP 1.1.
    >
    >
    > Cheers
    >
    > Gary Coutts
    >
    Steve C. Orr [MVP, MCSD], Apr 20, 2006
    #3
  4. Gary Coutts

    Gary Coutts Guest

    Thanks Steve,

    The articles were most helpful.

    Cheers

    Gary

    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:%...
    > You can email a page by using the WebRequest and MailMessage classes.
    >
    > Here are a couple examples:
    > http://www.aspalliance.com/stevesmith/articles/dotnetemailwebsite.asp
    > http://aspnet.4guysfromrolla.com/articles/091102-1.aspx
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    > "Gary Coutts" <> wrote in message
    > news:%...
    >> Hi,
    >>
    >> After dynamically generating an aspx page I need to email what is being
    >> displayed by the browser.
    >>
    >> I have looked at System.Web.Mail but it looks like you have to generate
    >> the body of the message as one long string.
    >>
    >> Can anyone point me in the right direction.
    >>
    >> I am using VS2003 ASP 1.1.
    >>
    >>
    >> Cheers
    >>
    >> Gary Coutts
    >>

    >
    >
    Gary Coutts, Apr 23, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    2
    Views:
    323
    tshad
    May 19, 2006
  2. Replies:
    9
    Views:
    1,274
  3. ColdAir
    Replies:
    1
    Views:
    771
    JeffP->
    Feb 26, 2009
  4. Porky

    ASP Page emailing text file

    Porky, Dec 1, 2003, in forum: ASP General
    Replies:
    6
    Views:
    175
    Aaron Bertrand [MVP]
    Dec 2, 2003
  5. Jess

    Attach file to Page for Emailing

    Jess, Aug 24, 2006, in forum: ASP General
    Replies:
    5
    Views:
    118
    Steven Burn
    Aug 24, 2006
Loading...

Share This Page