New System.Net.Mail.MailMessage Body Square characters
I am trying to create multiline body using VB 2005. I dynamically build up the body with the following code:
If strLine <>""Then
msgBuilder.Append(strLine.Trim() & Environment.NewLine)
EndIfAfter converting to string, the final result results are added to the Message.Body and the email is sent. There are no problems sending the message. The problem is that carriage return and linefeed appear as square boxes in the message body. I've tried using vbCrLf, vbLf, Chr(13), Chr(10). They all appear as square boxes in the message body.How can I force a new line in the message body without it appearing as a square character?
Can you get a trace log of the problem. Here is what I would suggest for your app.exe.config file (see http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx for more information on trace logging):
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.HttpListener">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Cache">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add
name="System.Net"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="System.Net.trace.log"
/>
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
<add name="System.Net.Cache" value="Verbose" />
<add name="System.Net.HttpListener" value="Verbose" />
</switches>
</system.diagnostics>
</configuration>