Hi
I am using StringBuilder to compose an email. The body of email consists of
a table for which data has to be taken fron SQL Server.
I use appen method to add text to the StringBuilder variable. When I am
finished I call ToString function to get the string.
The problem is that many times, it changes the text I appended to it. Like
when I append
<TH vAlign=top noWrap width=30>ABC<BR>10<BR>5<br>05</TH>
it some time changes that to
<TH vAlign=top noWrap width=30>Tue<BR>10<BR>5< br>05</TH>
some time it does this with other HTML attribute (mostly with < >). This
happens occasionaly. Sometime it works fine and sometime not.
I tried using the String instead of StringBuilder but the problem is still
there.
Please help me.
ramata - 12 May 2005 10:53 GMT
Once it changed:
<TH vAlign=top noWrap width=30><FONT face=Arial size=2 color="#ffffff"
>ABC<BR>6<BR>5<BR>05</FONT></TH>
to
<TH vAlign=top noWrap width=30><FONT face=Arial size=2 r="#ffffff"
colo>ABC<BR>6<BR>5<BR>05</FONT></TH>
strange behaviour
Thanks in advance
> Hi
>
[quoted text clipped - 19 lines]
>
> Please help me.
Cowboy (Gregory A. Beamer) - MVP - 12 May 2005 13:31 GMT
1. What version of the Framework?
2. What is the specific code you are using?
The StringBuilder is a character array. I am not sure how it would change
ABC to Tue (change char values), but I could see a possibility of changing
the order of letters. If it is changing char values, I would look at encoding
first. The order of letters sounds like a genuine bug.
As you have quotes, make sure they are properly escaped.
---
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
> Hi
>
[quoted text clipped - 19 lines]
>
> Please help me.
ramata - 12 May 2005 13:52 GMT
Sorry for my one mistake. The pattern ABC was replaced by me. The project I
am working on is confidential, so I tried to change Tue to ABC, but forget in
other place.
But, StringBuilder did changed
<FONT face=Arial size=2 color="#ffffff">
to
<FONT face=Arial size=2 r="#ffffff" colo>
I am using VStudio 2003 Vb.net and building for .net 1.1
Dick Grier - 13 May 2005 06:13 GMT
Code?

Signature
Richard Grier (Microsoft Visual Basic MVP)
See www.hardandsoftware.net for contact information.
Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.
Jon Skeet [C# MVP] - 12 May 2005 21:38 GMT
> I am using StringBuilder to compose an email. The body of email consists of
> a table for which data has to be taken fron SQL Server.
[quoted text clipped - 3 lines]
>
> The problem is that many times, it changes the text I appended to it.
I find that very hard to believe.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
ramata - 13 May 2005 07:26 GMT
The code is Vb.Net code. Basically two procedures. One composes email and
other sends it. This can be put in any Vb.net class and calling SendEmail()
Public Sub GetEmailBody(ByRef strHTMLMessage As StringBuilder)
Dim strQuery As String
Dim Adodc1 As ADODB.Recordset
strHTMLMessage.Remove(0, strHTMLMessage.Length)
' create HTML message
strHTMLMessage.Append("<html><head><title>My page</title> " _
& "<style type=""text/css"">th {color:
#ffffff;font: bold 12px arial} td.b {color: #ffffff;font: bold 12px arial}
</style></head><body>" _
& "<table align=center border=1 cellspacing=0
cellpadding=1 style='border-collapse: collapse' bordercolor=#777777>" _
& "<tr bgcolor=#ff0000>" _
& "<th nowrap valign=top align=left
width=200>col1</th>" _
& "<th valign=top>col2</th>" _
& "<th nowrap valign=top>col3<br>one<br>two</th>" _
Adodc1 = New ADODB.Recordset
Dim strQuery As String = "SELECT * FROM sample"
' conn is global Adodb.Connection
Adodc1.Open(strQuery, conn)
If Not Adodc1.EOF Then
Do Until Adodc1.EOF
strHTMLMessage.Append(vbCrLf & "<tr bgcolor=#ffcccc>")
strHTMLMessage.Append("<td nowrap align=left>" &
tmpPlay.StationName & "</td><td nowrap align=left>" &
tmpPlay.PresentationRegion & "</td>")
loop
strHTMLMessage.Append("</tr>")
Next
' end of table
strHTMLMessage.Append("</table>")
strHTMLMessage.Append("</body></html>")
End Sub
Public Sub SendEmail()
Dim strBody As New StringBuilder
Dim mailmsg As CDO.Message
Dim Conf As CDO.Configuration
mailmsg = New CDO.Message
mailmsg.Configuration.Load(CDO.CdoConfigSource.cdoIIS)
eMailFrom = "abc@yahoo.com"
GetEmailBody(strBody)
eMailSubject = "testing"
With mailmsg
.From = eMailFrom
.Subject = eMailSubject
.To = recp(i).email
.HTMLBody = strBody.ToString
.Send()
End With
End Sub
Jon Skeet [C# MVP] - 13 May 2005 07:33 GMT
> The code is Vb.Net code.
<snip>
See http://www.pobox.com/~skeet/csharp/incomplete.html

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too