[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

vbcrlf not working on aspx page

Posted on 2008-02-12
10
Medium Priority
?
588 Views
Last Modified: 2012-06-27
I have the following code snippet within a aspx page.  I want the text to be on two lines.  I have seemed to have tried everything to get this to do a vbcrlf.  Here is the lastest attempt.  Can anyone tell me why it doesnt work and how to make it work.  I have used vbcrlf instead and still everything is on the same line.



<head>
<script type="VB" runat="server" > 
 
Sub submit(s As Object, e As EventArgs) 
	
	SendConfirmation
	
End Sub 
Private Function SendConfirmation()
	dim message as string
	Dim nl As String = "%0D%0A"
	dim objMail as new mailmessage()
	message = "Your email message has been received and you will receive a response shortly" & nl & "Thank You for contacting TheApartmentGallery.com"
	objmail.to = txtemailaddress.text
	objmail.from = "Webmaster@theapartmentgallery.com"
	objmail.subject = "Auto Response From the Apartment Gallery"
	objmail.body = message
	objmail.cc = "bkatherman@theapartmentgallery.com"
	smtpMail.send(objMail)
  	SERVER.EXECUTE("sent.aspx")
 
End Function

Open in new window

0
Comment
Question by:mgmhicks
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 20876973
In HTML, you indicate a new line using <br />

message = "Your email message has been received and you will receive a response shortly.<br />Thank You for contacting TheApartmentGallery.com"
0
 
LVL 4

Accepted Solution

by:
cmcawood earned 2000 total points
ID: 20876986
Have u tried
message = "Your email message has been received and you will receive a response shortly" & vbCrLf & "Thank You for contacting TheApartmentGallery.com"
	

Open in new window

0
 
LVL 38

Expert Comment

by:PaulHews
ID: 20877003
Sorry, it's a mail message...  You need to enter real line break instead of URL encoding it.

message = "Your email message has been received and you will receive a response shortly" & Environment.NewLine() & "Thank You for contacting TheApartmentGallery.com"




0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 38

Expert Comment

by:PaulHews
ID: 20877089
If that fails, then you would need to use

objmail.BodyFormat = MailFormat.Html

and encode the line as

message = "Your email message has been received and you will receive a response shortly<br />Thank You for contacting TheApartmentGallery.com"

The thing is that many SMTP servers will disallow hard line breaks in text format.


0
 
LVL 19

Expert Comment

by:daveamour
ID: 20877337
Also watch out for Outlook removing line breaks - look at the top of the message to check this.
0
 

Author Comment

by:mgmhicks
ID: 20877706
this code is wrapped around the <script type="VB" runat="server" > script.  So its in vb code.  No of the suggestions have worked.  I am using vb script on a aspx page.   Still no go.  
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 20877802
What happened when you tried this:

objmail.BodyFormat = MailFormat.Html

message = "Your email message has been received and you will receive a response shortly<br />Thank You for contacting TheApartmentGallery.com"
0
 

Author Comment

by:mgmhicks
ID: 20877987
This is what I got after doing that.

Your email message has been received and you will receive a response shortlyThank You for contacting TheApartmentGallery.com
0
 
LVL 4

Expert Comment

by:cmcawood
ID: 20891339
I tested it out with both my suggestion and PaulHews one, here is the code I used and it worked 100% with both.
<%@ Import Namespace="System" %> 
<%@ Import Namespace="System.Web.Mail" %> 
 
<head>
<script type="VB" runat="server" > 
 
Private Function SendConfirmation()
 
	SmtpMail.SmtpServer = "your.mailserver.here"
 
	Dim message As String
	dim objMail as new MailMessage()
	message = "Your email message has been received and you will receive a response shortly" & VbCrLf & "Thank You for contacting TheApartmentGallery.com"
	objmail.to = "my@email.goes.here"
	objmail.from = "your@email.goes.here"
	objmail.subject = "Auto Response From the Apartment Gallery"
	objmail.body = message
 
	SmtpMail.Send(objmail)
 
End Function
 
Sub Page_Load(sender As Object, e As EventArgs)
	SendConfirmation()
End Sub
 
</script>
</head>

Open in new window

0
 

Author Closing Comment

by:mgmhicks
ID: 31431162
Thank you the vbcrlf statement is the one that works with the vb script.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question