Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

Format Text

$
0
0
Hi,

I am working with asp.net and SQL Server..
Now, I have an email sent out with the code below;
Code:

Private Sub Authorsendemail()

        Using message As New MailMessage()

            'Dim msgbody As String = String.Empty

            Dim htmlFile As String = Server.MapPath("~/EmailTemplate/NewChangeRequest.htm")
            Dim sreader As New StreamReader(htmlFile)
            Dim msgBody As New StringBuilder(sreader.ReadToEnd)
            sreader.Close()

            msgBody.Replace("<%reference%>", Trim(txtref.Text.ToString()))
            msgBody.Replace("<%author%>", Trim(cmbchngcrt.SelectedItem.ToString()))
            msgBody.Replace("<%requirement%>", Trim(txtreq.Text.ToString()))


            message.From = New MailAddress(findemail(cmbchngcrt.SelectedItem.ToString))
            message.[To].Add(New MailAddress(findemail(cmbpeername.SelectedItem.ToString)))
            message.[CC].Add(New MailAddress(findemail(cmbchngcrt.SelectedItem.ToString)))


            message.Subject = "Change Request Enquiry: " + Trim(txtref.Text.ToString())
            message.IsBodyHtml = True
            message.Body = msgBody.ToString
            Dim client As New SmtpClient()
            client.Send(message)

            sreader.Dispose()

        End Using

    End Sub

Works Fine..

The problem is <%requirement%> - the code doesnt recognise a space or a break.. instead it joins the entire saved text as one paragraph..



E.g:

Good afternoon.

My name is "John Smith" and I really need you help on this.

Thank you



Email will be;

Good afternoon.My name is "John Smith" and I really need you help on this.Thank you

On the email template I have;

Code:

<div id="content">
         
                    <h3> Change Control Request - Review </h3>

                    <p>  I have submitted a change control request <b>Ref:
<%reference></b>)                    <br />
                    Please <a href="http://www.test.com">click here</a> to log on to the System to review and agree the request.
                    </p>
                    <p>
                        <b>See the details below:</b>
                        <br /><%requirement%>
                    </p>

                    <p>This is an automated message from the CCMS.</p>
                    <p>Thank you,  <br />
                    <%author%></p>
              </div>

How can i enforce the format as requested. Because in SQL Server the data is saved with spaces and breaks.

Thank you

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>