I am using the standard .NET method of sending an email. My users will
be filling out a web form with various pieces of information. I have
created a control with properties that are the same as the items on
the form. When the user clicks submit, my code is as follows:
InformationRequest req = new InformationRequest();
req.FirstName = this.txtFirstName.Text;
req.LastName = this.txtLastName.Text;
req.Title = this.txtTitle.Text;
req.Address1 = this.txtAddress1.Text;
req.Address2 = this.txtAddress2.Text;
req.City = this.txtCity.Text;
req.State = this.cboState.SelectedItem.Value;
req.Zip = this.txtZIP.Text;
req.Phone = this.txtPhone.Text;
req.Fax = this.txtFax.Text;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter(sb);
System.Web.UI.HtmlTextWriter writer = new HtmlTextWriter(sw);
req.RenderControl(writer);
SmtpMail.SmtpServer = "192.168.0.10";
SmtpMail.Send(From, To, Subject, sb.ToString());
//End of code
When I send the email, it comes through, but there is no message body.
In addition, if I try to Response.Write the contents of the
stringbuilder, there isn't anything there. What is causing the control
not to render? All the control contains is a bit of HTML code and <%
%> blocks where it reads from its properties.
Any ideas?
Thanks,
Will Gant
Fo*******@hotmail.com