473,587 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems emailing a control

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:

InformationRequ est req = new InformationRequ est();
req.FirstName = this.txtFirstNa me.Text;
req.LastName = this.txtLastNam e.Text;
req.Title = this.txtTitle.T ext;
req.Address1 = this.txtAddress 1.Text;
req.Address2 = this.txtAddress 2.Text;
req.City = this.txtCity.Te xt;
req.State = this.cboState.S electedItem.Val ue;
req.Zip = this.txtZIP.Tex t;
req.Phone = this.txtPhone.T ext;
req.Fax = this.txtFax.Tex t;

System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
System.IO.Strin gWriter sw = new System.IO.Strin gWriter(sb);
System.Web.UI.H tmlTextWriter writer = new HtmlTextWriter( sw);
req.RenderContr ol(writer);

SmtpMail.SmtpSe rver = "192.168.0. 10";
SmtpMail.Send(F rom, 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*******@hotma il.com
Nov 18 '05 #1
2 1079
This might not have anything to do with it, but chances are your
InformationRequ est WebControl is rendering Html. You should set the
MailMessage.Bod yFormat to have it as Html.

If you were to do a Response.Write on sb.ToString() would it render the
proper information to the browser?

//begin code snippet
using System.Web.Mail ;

MailMessage email = new MailMessage();

email.From = From;
email.To = To;
email.Subject = Subject;
email.Body = sb.ToString()
email.BodyForma t = MailFormat.Html ;

SmtpMail.SmtpSe rver = "192.168.0. 10";
SmtpMail.Send( email );

//end code snippet

HTH,
bill

"Foehammer" <fo*******@hotm ail.com> wrote in message
news:27******** *************** ***@posting.goo gle.com...
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:

InformationRequ est req = new InformationRequ est();
req.FirstName = this.txtFirstNa me.Text;
req.LastName = this.txtLastNam e.Text;
req.Title = this.txtTitle.T ext;
req.Address1 = this.txtAddress 1.Text;
req.Address2 = this.txtAddress 2.Text;
req.City = this.txtCity.Te xt;
req.State = this.cboState.S electedItem.Val ue;
req.Zip = this.txtZIP.Tex t;
req.Phone = this.txtPhone.T ext;
req.Fax = this.txtFax.Tex t;

System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
System.IO.Strin gWriter sw = new System.IO.Strin gWriter(sb);
System.Web.UI.H tmlTextWriter writer = new HtmlTextWriter( sw);
req.RenderContr ol(writer);

SmtpMail.SmtpSe rver = "192.168.0. 10";
SmtpMail.Send(F rom, 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*******@hotma il.com

Nov 18 '05 #2
It still comes out completely blank. It seems that calling the RenderControl method doesn't output anything. BTW, the control is a usercontrol, not a server control, if that helps. I set the body format to HTML and it didn't change anything. I think the principal problem is that the control is not dumping out the HTML.

"William F. Robertson, Jr." wrote:
This might not have anything to do with it, but chances are your
InformationRequ est WebControl is rendering Html. You should set the
MailMessage.Bod yFormat to have it as Html.

If you were to do a Response.Write on sb.ToString() would it render the
proper information to the browser?

//begin code snippet
using System.Web.Mail ;

MailMessage email = new MailMessage();

email.From = From;
email.To = To;
email.Subject = Subject;
email.Body = sb.ToString()
email.BodyForma t = MailFormat.Html ;

SmtpMail.SmtpSe rver = "192.168.0. 10";
SmtpMail.Send( email );

//end code snippet

HTH,
bill

"Foehammer" <fo*******@hotm ail.com> wrote in message
news:27******** *************** ***@posting.goo gle.com...
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:

InformationRequ est req = new InformationRequ est();
req.FirstName = this.txtFirstNa me.Text;
req.LastName = this.txtLastNam e.Text;
req.Title = this.txtTitle.T ext;
req.Address1 = this.txtAddress 1.Text;
req.Address2 = this.txtAddress 2.Text;
req.City = this.txtCity.Te xt;
req.State = this.cboState.S electedItem.Val ue;
req.Zip = this.txtZIP.Tex t;
req.Phone = this.txtPhone.T ext;
req.Fax = this.txtFax.Tex t;

System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
System.IO.Strin gWriter sw = new System.IO.Strin gWriter(sb);
System.Web.UI.H tmlTextWriter writer = new HtmlTextWriter( sw);
req.RenderContr ol(writer);

SmtpMail.SmtpSe rver = "192.168.0. 10";
SmtpMail.Send(F rom, 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*******@hotma il.com


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1833
by: Jonathan M. Rose | last post by:
I am looking for a script that I can sit on an HTML server (Linux, Apache, PHP/Perl/Python/Etc.) that will allow me to do the following things: 1) Post news articles that consists of (i) a title and (ii) a body. 2) Show the last X posts (or, better yet, just the last X titles) on a home page. 3) Show all posts on a "news" page. 4) When a...
10
8171
by: Fawke101 | last post by:
Hi there, I have a date field in SQL server - that holds dates as DD/MM/YYYY format (GB). Now, i have an ASP application that Adds/Edits records in this table; and i am having real problems with the date field in the ADD and EDIT (update) part for this app. Basically, i receive and Error as below:
3
1530
by: John | last post by:
Hi All, I have a database with a button that when it is click it sends an email to the client. This email button works without any problems in other computers. On Thursday we bought a new computer, and this particular button does not function on the new computer. I installed several version of Outlook from 2000 to 2003 and still doesn't...
19
2968
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and provide an open TD with a DIV in it for the content of this formlet. (The DIV is for DHTML to hide and show the content) I've created a web page...
3
3027
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a App_Start handler to see if I could get emailed at all even from the first request of the app, but to no avail. Could someone please help me out? ...
4
1645
by: Mike Moore | last post by:
What is the best way to launch outlook from an asp.net web page? Can you do this using MAPI or is there a control that you can purchase? We are unable to use SMTP. We use MS Exhange and MAPI currently for our client/server apps.
5
1251
by: Elmo Watson | last post by:
I'm having weird problems emailing on the Win2003 Staging environment - - the same script runs on multiple other computers, but on this one, the smtp service is running, but when the send is done (same exact script as on other working computers), it looks like it posts back, but nothing is sent - nothing is in any of the MailRoot folders. ...
2
1766
by: electrixnow | last post by:
I am about to pull my hair out! I have VS 2005 PRO and I am coding in C++ I have a console program that parses data and creates a text output. I need to use MSWords mailmerge to merge the text output and save the doc for emailing later. I have a macro in MSWord that merges the data from the textfile with the doc. I have looked everywhere...
0
1923
by: Alan | last post by:
Hello World: I'm trying to build an application (using Access 2003) that will allow users who have to perform tasks in a particular order, to notify the next person in line when their task is complete. I'm trying to have the application send an email to the next person upon task completion. I looked over the info concerning emailing and...
0
7852
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.