473,326 Members | 2,805 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,326 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 1837
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.