473,795 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create an html e-mail using asp.net

I am using stringbuilder to create a html email message that is basically a
two column table with the field name in one column, and the field value in
another, and about 30 rows. I don't get any errors when the code runs, but
there seems to be always one field that has the wrong background color, or
has a "!" in the text of the e-mail message. On the e-mail message, when I
click "View Source", I see that at the end of many rows, there is a "!"
character at the end. So, instead of bgcolor="#b0e0e 6", I see bgcolor="#b!
and then you have go down one line and all the way to the left (in view
source), to see the rest of the characters; 0e0e6". The location of this
error is different in other e-mails and depends on how many fields I put in
the particular e-mail. If I create a really short e-mail, then I don't have
this problem. Has anyone encountered this? Any help would be appreciated.
Here is the example code;

Dim strMessage As New StringBuilder

strMessage.Appe nd("<html>")
strMessage.Appe nd("<body>")
strMessage.Appe nd("<table width=""100%"" border=""1"" align=""center" "
cellpadding=""2 "" cellspacing=""1 "">")

strMessage.Appe nd("<tr>")
strMessage.Appe nd("<td width=""40%""
bgcolor=""#b0e0 e6""><strong><f ontcolor=""#000 099"" size=""2"">")
strMessage.Appe nd("Project Number")
strMessage.Appe nd("</strong></td>")
strMessage.Appe nd("<td width=""60%""
bgcolor=""#b0e0 e6""><strong><f ontcolor=""#000 099"" size=""2"">")
strMessage.Appe nd(strProjnum)
strMessage.Appe nd("</strong></td>")
strMessage.Appe nd("</tr>")

strMessage.Appe nd("<tr>")
strMessage.Appe nd("<td width=""40%""
bgcolor=""#b0e0 e6""><strong><f ontcolor=""#000 099"" size=""3"">")
strMessage.Appe nd("Request Number")
strMessage.Appe nd("</font></strong></td>")
strMessage.Appe nd("<td width=""60%""
bgcolor=""#b0e0 e6""><strong><f ontcolor=""#000 099"" size=""4"">")
strMessage.Appe nd(strRequestnu m)
strMessage.Appe nd("</font></strong></td>")
strMessage.Appe nd("</tr>")

strMessage.Appe nd("</table>")
strMessage.Appe nd("</body>")
strMessage.Appe nd("</html>")

Dim newMail As New MailMessage

newMail.From = "hr******@jcpen ney.com"
newMail.To ="au*****@jcpen ney.com"

newMail.Subject = "Hardware Request Confirmation - New"
newMail.Body = strMessage.ToSt ring
newMail.BodyFor mat = MailFormat.Html

SmtpMail.SmtpSe rver = "mailserver.jcp enney.com"
SmtpMail.Send(n ewMail)

Jul 21 '05 #1
1 1857
The problem is your are sending the entire message as a single line and that
lines length is over the supported length of the server. You can either
break your lines manually using VBCRLF or you can use a 3rd party product
that will do it for you.

You could use the http://www.freesmtp.net component. Just turn on
quoted-printable encoding and it will wrap the lines for you.

i.e.

strMessage.Appe nd("<html>" & vbcrlf)
strMessage.Appe nd("<body>" & vbcrlf)

76 characters per line is a safe length to send at because that number is
supported by all servers.
"aur56" <au***@discussi ons.microsoft.c om> wrote in message
news:88******** *************** ***********@mic rosoft.com...
I am using stringbuilder to create a html email message that is basically a
two column table with the field name in one column, and the field value in
another, and about 30 rows. I don't get any errors when the code runs,
but
there seems to be always one field that has the wrong background color, or
has a "!" in the text of the e-mail message. On the e-mail message, when
I
click "View Source", I see that at the end of many rows, there is a "!"
character at the end. So, instead of bgcolor="#b0e0e 6", I see
bgcolor="#b!
and then you have go down one line and all the way to the left (in view
source), to see the rest of the characters; 0e0e6". The location of this
error is different in other e-mails and depends on how many fields I put
in
the particular e-mail. If I create a really short e-mail, then I don't
have
this problem. Has anyone encountered this? Any help would be
appreciated.
Here is the example code;

Dim strMessage As New StringBuilder

strMessage.Appe nd("<html>")
strMessage.Appe nd("<body>")
strMessage.Appe nd("<table width=""100%"" border=""1"" align=""center" "
cellpadding=""2 "" cellspacing=""1 "">")

strMessage.Appe nd("<tr>")
strMessage.Appe nd("<td width=""40%""
bgcolor=""#b0e0 e6""><strong><f ontcolor=""#000 099"" size=""2"">")
strMessage.Appe nd("Project Number")
strMessage.Appe nd("</strong></td>")
strMessage.Appe nd("<td width=""60%""
bgcolor=""#b0e0 e6""><strong><f ontcolor=""#000 099"" size=""2"">")
strMessage.Appe nd(strProjnum)
strMessage.Appe nd("</strong></td>")
strMessage.Appe nd("</tr>")

strMessage.Appe nd("<tr>")
strMessage.Appe nd("<td width=""40%""
bgcolor=""#b0e0 e6""><strong><f ontcolor=""#000 099"" size=""3"">")
strMessage.Appe nd("Request Number")
strMessage.Appe nd("</font></strong></td>")
strMessage.Appe nd("<td width=""60%""
bgcolor=""#b0e0 e6""><strong><f ontcolor=""#000 099"" size=""4"">")
strMessage.Appe nd(strRequestnu m)
strMessage.Appe nd("</font></strong></td>")
strMessage.Appe nd("</tr>")

strMessage.Appe nd("</table>")
strMessage.Appe nd("</body>")
strMessage.Appe nd("</html>")

Dim newMail As New MailMessage

newMail.From = "hr******@jcpen ney.com"
newMail.To ="au*****@jcpen ney.com"

newMail.Subject = "Hardware Request Confirmation - New"
newMail.Body = strMessage.ToSt ring
newMail.BodyFor mat = MailFormat.Html

SmtpMail.SmtpSe rver = "mailserver.jcp enney.com"
SmtpMail.Send(n ewMail)

Jul 21 '05 #2

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

Similar topics

2
4082
by: Nick | last post by:
Loop to create an array from a dynamic form. I'm having trouble with an application, and I'll try to explain it as clearly as possible: 1. I have a form with two fields, say Apples and Oranges. The user selects from a drop down menu, between 1-10 of each and clicks submit. The resulting page will display a NEW form, with rows and a list of fields for the amount of each items selected.
2
10705
by: Michael Hertz | last post by:
Assume there is a XSD schema which describes the maximum possible number of fields which can occur in a XML document. How do I create such a form either as a HTML form or a text file from the XSD schema source? The DOM tree is automatically created by the parser. So there is only the need to create a form from this DOM tree. I feel that such a tool should be already available because it is a standard task. Does someone know such a...
4
24187
by: Andrew V. Romero | last post by:
I have been working on a function which makes it easier for me to pull variables from the URL. So far I have: <script language="JavaScript"> var variablesInUrl; var vArray = new Array(); function loadUrlVariables() { varString = location.search;
1
47750
by: Jim, N2VX | last post by:
I'd like to create/display an Excel spreadsheet from javascript. We have an HTML page with results of a search and it can be reasonably large. The first attempt was to format the data into an HTML table and send it to an ASP page. The ASP page has: Response.AddHeader ("Content-Disposition", "inline"); Response.ContentType = "application/vnd.ms-excel"); Response.Write(formatted_html_data);
8
10327
by: RC | last post by:
The following code works well to create an html file that has a row for each row in my table. My Access 2002 database has a tabel with 3 columns labeled, Model, CD and Hard Drive (HD). Any suggestions to change the code to make one html page for each Model? Maybe run the code on a table query? Private Sub sCreateStaticHTMLFiles_Click() Dim db As DAO.Database Dim rs As DAO.Recordset Dim strHTMLFile As String
6
2303
by: Frank Wilson | last post by:
Tom, It sounds to me like ASP, not ASP.NET is handling the request for WebForm1.aspx. This is most likely an IIS config issue that may have been caused by order of installation or reinstallation, or possibly even something that happened in IIS before .NET was installed. Here is a way to prove or disprove my theory:
18
2723
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html In this post, I'm especially soliciting review of Carl Banks's point (now discussed under Open Issues) which asks if it would be better to have the create statement translated into:
14
6143
by: mistral | last post by:
Need php script to create mySQL database programmatically; since hosting configuration may not allow create database from script, script also need eliminate/rewrite all restrictions in appropriate places in that hosting.
1
2042
by: sebastian.janoschka | last post by:
Hello javascript newsgroup, Sorry for my bad english please... Today I have write some of my first JS scripts. My problem is to create a <spantag in the div tag with the name "favoriten". In the first step I create the span tag in the "hinzufügen" function
2
2785
by: nja2222 | last post by:
I would like to create a page for my clients to login and check for updates on their accounts. Then I would like to create a page where my employees can login and make updates, specifically new file uploads, to the clients accounts. I have seen similar sites everywhere, such as bank websites, USPS site, et cetera. What is required to accomplish this? I'm trying to do this with the PHP, MySQL and Adobe CS3 Master collection's 'Dreamweaver CS3' ...
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10448
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10167
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9046
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6784
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2922
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.