We help IT Professionals succeed at work.

New line character in classic ASP

mmalik15
mmalik15 asked
on
Below is my string and i m using <br> to acheive a new line in the browser but it does not work. I have also tried \n and vbcrlf but non are working for me. Any ideas

<% Email=Username & " has placed a request for a journal article. The details of the request are below Purpose of Request: " & ReqPurpose & " <br> Title of Journal: " & Jnltitle & " <br> Source: " &SourceName & " <br> ISSN: " &Request.Form("txtISSN") & " <br> Journal Year: " &Request.Form("txtJrlYear")  & " <br> Journal Volume: " &Request.Form("txtJrlVol") & " <br> Journal Part: " &Request.Form("txtJrlIssue") & " <br> Article: " &Request.Form("txtAuthororArticle") & " <br> Title of Article: " &Request.Form("txtTitleOfArticle")  & " <br> Pages to Photocopy: " &Request.Form("txtPagesToPhotocopy") & " <br> Notes to Library: " &Request.Form("txtNoteToLibrary") & ",<br> Thank you" %>
Comment
Watch Question

Commented:
are you using vb?

& vbCrLF & " Title of Journal bla bla " & Jnititle & vbCrLF & " bla blah"
Wayne BarronAuthor, Web Developer
Top Expert 2009

Commented:
It works for me, just as it is.
What browser are you using?

I test with the new Google Chrome and IE8

Carrzkiss

Commented:
not only the browser but if using for example html5 or xhtml you need to use <br /> so it'd be good to know browser + html version
Wayne BarronAuthor, Web Developer
Top Expert 2009

Commented:
baretree is correct.
I forgot all about the <br />, that is usually the first thing I get people to change over.

Author

Commented:
i did try <br /> as the first thing and tried them in both IE and firebox. This is how i m sending the email

<% Email=Username & " has placed a request for a journal article. The details of the request are below Purpose of Request: " & ReqPurpose & " <br> Title of Journal: " & Jnltitle & " <br> Source: " &SourceName & " <br> ISSN: " &Request.Form("txtISSN") & " <br> Journal Year: " &Request.Form("txtJrlYear")  & " <br> Journal Volume: " &Request.Form("txtJrlVol") & " <br> Journal Part: " &Request.Form("txtJrlIssue") & " <br> Article: " &Request.Form("txtAuthororArticle") & " <br> Title of Article: " &Request.Form("txtTitleOfArticle")  & " <br> Pages to Photocopy: " &Request.Form("txtPagesToPhotocopy") & " <br> Notes to Library: " &Request.Form("txtNoteToLibrary") & ",<br> Thank you" %>

<% emailnotification = "****@gmail.com" %>
<% emailsentto = "****@gmail.com" %>

<%
Set objMail = Server.CreateObject("CDONTS.NewMail")

objMail.Send emailnotification,emailsentto,"New Journal Request Waiting",Email,2

Set objMail = nothing
%>



dont know if there is something else causing this prob

Author

Commented:
I am using the default html set in vs 2010 and guess its 1.0 and iv tried in IE 9.0
And the latest version of firefox. I've used <br /> frequently in asp.net without any line break issues. I m a begginner in ASP and don't know what I am doing wrong  here
Commented:
Thing is you can send an using CDONTS as either text only, HTML or multipart. If you send as text use VbCrLf to do line breaks. If you use HTML use <br> or <br /> (they while probably both work despite breaking validation). At the moment you seem to be trying to send a text email with html line breaks, so the received message won't be interpreted as html and the line breaks will fail. Try using a full html message complete with body tags etc as per this article.http://support.microsoft.com/kb/189945
Wayne BarronAuthor, Web Developer
Top Expert 2009
Commented:
CDONTS is a bad thing to use, it is not used by many any more.
CDOSYS, is what everyone is using, either than 3rd party tools.
www.powerasp.com/content/new/sending_email_cdosys.asp
Method 3 is what I use.
In the option, use
ObjSendMail.HTMLBody
and with this, use your <br />

Good Luck
Carrzkiss

Commented:
The definition of a "new line" differs per operating system. There is the "linefeed" and the "carriage return", look them up on http://www.asciitable.com. The first has ascii code 10 the second has ascii code 13. Windows uses "carriage return" + "linefeed". Linux systems do only with "linefeed". Older Apple systems did only "carriage return" (not sure if that still is the case with the BSD-based apple OS).

In VBScript you can generate ascii code characters by CHR(n), where n is the number.

Usually CHR(10) is enough to get a new line, even in Windows (but it does for example not work is Windows Notepad).




Author

Commented:
Thanks guys