vbCrLf

  • Thread starter Thread starter dancer
  • Start date Start date
Then why do I not get new lines with this code?

'Set the body
objMM.Body = DateTime.Now + " feedback was sent from an ASP.NET " &
_
"Wheeler's Accident Investigation Form" & _
vbCrLf &vbCrLf & _
Check1.Text & "." & vbCrLf & vbCrLf & _
vbCrLf &vbCrLf & _
Check2.Text & vbCrLf
 
Probably because you're writing HTML.

vbCrLf only works within VB.NET code.

If you're writing HTML, use <br> :

'Set the body
objMM.Body = DateTime.Now + " feedback was sent from an ASP.NET " & _
"Wheeler's Accident Investigation Form" & "<br>" & Check1.Text & "." & "<br>" & Check2.Text & "<br>"




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
I am confused.

You will notice that this is VB, not HTML. What do I use so that
Location.Text and Check1.Text and Check2.Text will be on a new line when
they appear in the e-mail?

<script language="VB" runat="server">


Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class
Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out
the
'feedback form.
objMM.To = (e-mail address removed)

objMM.From = "(e-mail address removed)"
'send in html format
objMM.BodyFormat = MailFormat.Html
'Set the priority - options are High, Low, and Normal
objMM.Priority = MailPriority.Normal

'Set the subject
objMM.Subject = "Accident Investigation Form"

'Set the body
objMM.Body = DateTime.Now + " " & _
Location.Text & _
vbCrLf & vbCrLf & _
Check1.Text & "." & vbCrLf & vbCrLf & _
vbCrLf &vbCrLf & _
Check2.Text & vbCrLf

'Specify to use the default Smtp Server
SmtpMail.SmtpServer = ""
'Now, to send the message, use the Send method of the SmtpMail class
SmtpMail.Send(objMM)
panelSendEmail.Visible = false
panelMailSent.Visible = true
End Sub
 
But you don't use <br> in VB do you? Only in HTML?

when you have

objMM.BodyFormat = MailFormat.Html

you have to use HTML - so, you have to use a <br> tag

when you will change

objMM.BodyFormat = MailFormat.Text

you can use vbCrLf to make new lines.

In this case your email message will be sent as a plain text.
 
re:
!> You will notice that this is VB, not HTML.

Actually, it *is* HTML.

Maybe you missed this line :

'send in html format

What you are doing in that code is *composing HTML*.





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
Back
Top