Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to email a rendered page.

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
I want the rendered page to appear in the body of an e-mail. To do this it seems I have to render the page to a Writer object (something I'm new to). So here is what I have now:
Code:
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
  Dim newMail As New Mail.MailMessage()
  Dim newStr As New System.IO.StringWriter()
  Dim newHtml As New HtmlTextWriter(newStr)
  Dim bodyStr As String
  Me.Page.RenderControl(newHtml)
  newHtml.Write(bodyStr)
  With newMail
   .From = "cs@centurycolor.com"
   .To = "mark@centurycolor.com"
   .Subject = Me.lblFormTitle.Text & " Order"
   .Body = bodyStr
  End With
  SmtpMail.SmtpServer = "mail.centurycolor.com"
  SmtpMail.Send(newMail)
 End Sub

I get the message:
System.Web.HttpException: A page can have only one server-side Form tag.

From the stack trace it seems to happen when I render. But the e-mail still goes thru?? (Tho blank.)
 
Actually this happenes when we assign the SmtpServer. If I don't assign the SmtpServer I get this message:
System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top