473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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="#b0e0e6", 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.Append("<html>")
strMessage.Append("<body>")
strMessage.Append("<table width=""100%"" border=""1"" align=""center""
cellpadding=""2"" cellspacing=""1"">")

strMessage.Append("<tr>")
strMessage.Append("<td width=""40%""
bgcolor=""#b0e0e6""><strong><fontcolor=""#000099"" size=""2"">")
strMessage.Append("Project Number")
strMessage.Append("</strong></td>")
strMessage.Append("<td width=""60%""
bgcolor=""#b0e0e6""><strong><fontcolor=""#000099"" size=""2"">")
strMessage.Append(strProjnum)
strMessage.Append("</strong></td>")
strMessage.Append("</tr>")

strMessage.Append("<tr>")
strMessage.Append("<td width=""40%""
bgcolor=""#b0e0e6""><strong><fontcolor=""#000099"" size=""3"">")
strMessage.Append("Request Number")
strMessage.Append("</font></strong></td>")
strMessage.Append("<td width=""60%""
bgcolor=""#b0e0e6""><strong><fontcolor=""#000099"" size=""4"">")
strMessage.Append(strRequestnum)
strMessage.Append("</font></strong></td>")
strMessage.Append("</tr>")

strMessage.Append("</table>")
strMessage.Append("</body>")
strMessage.Append("</html>")

Dim newMail As New MailMessage

newMail.From = "hr******@jcpenney.com"
newMail.To ="au*****@jcpenney.com"

newMail.Subject = "Hardware Request Confirmation - New"
newMail.Body = strMessage.ToString
newMail.BodyFormat = MailFormat.Html

SmtpMail.SmtpServer = "mailserver.jcpenney.com"
SmtpMail.Send(newMail)

Jul 21 '05 #1
1 1839
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.Append("<html>" & vbcrlf)
strMessage.Append("<body>" & vbcrlf)

76 characters per line is a safe length to send at because that number is
supported by all servers.
"aur56" <au***@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.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="#b0e0e6", 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.Append("<html>")
strMessage.Append("<body>")
strMessage.Append("<table width=""100%"" border=""1"" align=""center""
cellpadding=""2"" cellspacing=""1"">")

strMessage.Append("<tr>")
strMessage.Append("<td width=""40%""
bgcolor=""#b0e0e6""><strong><fontcolor=""#000099"" size=""2"">")
strMessage.Append("Project Number")
strMessage.Append("</strong></td>")
strMessage.Append("<td width=""60%""
bgcolor=""#b0e0e6""><strong><fontcolor=""#000099"" size=""2"">")
strMessage.Append(strProjnum)
strMessage.Append("</strong></td>")
strMessage.Append("</tr>")

strMessage.Append("<tr>")
strMessage.Append("<td width=""40%""
bgcolor=""#b0e0e6""><strong><fontcolor=""#000099"" size=""3"">")
strMessage.Append("Request Number")
strMessage.Append("</font></strong></td>")
strMessage.Append("<td width=""60%""
bgcolor=""#b0e0e6""><strong><fontcolor=""#000099"" size=""4"">")
strMessage.Append(strRequestnum)
strMessage.Append("</font></strong></td>")
strMessage.Append("</tr>")

strMessage.Append("</table>")
strMessage.Append("</body>")
strMessage.Append("</html>")

Dim newMail As New MailMessage

newMail.From = "hr******@jcpenney.com"
newMail.To ="au*****@jcpenney.com"

newMail.Subject = "Hardware Request Confirmation - New"
newMail.Body = strMessage.ToString
newMail.BodyFormat = MailFormat.Html

SmtpMail.SmtpServer = "mailserver.jcpenney.com"
SmtpMail.Send(newMail)

Jul 21 '05 #2

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

Similar topics

2
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...
2
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...
4
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(); ...
1
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...
8
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...
6
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...
18
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...
14
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...
1
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". ...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.