Solved

Format string with carriage return for mail message

Posted on 2001-08-13
10
255 Views
Last Modified: 2008-01-09
Hi Guys,
I am creating a HTML form with various input fields and when the user submits details they are entered in an SQL Server table.
But also I am e-mailing these details to certain people.
I am using CDONTS - (Set objCDO = Server.CreateObject("CDONTS.NewMail")
The body of the mail message will consist of all the details from the HTML form.
It is easy to read in all details from HTML form fileds and assign them to a string variable and then assign this string as the mail message body

objCDO.Body = string

But I want to put a carriage return after each form detail as I am reading it into string so as my message is nicely formatted when recipient gets it

Example
-------------------------------------
From: Willy Balda
Department: Extronics
Details: Testing Results - Completed
-------------------------------------
Any ideas appreciated

Cheers


B Cunney



0
Comment
Question by:Barry Cunney
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 1

Expert Comment

by:russoffl
Comment Utility
str & "<br>" should do it.

or

Response.Write("From: " & Request.Form("whatever") & "<br")
0
 
LVL 1

Expert Comment

by:russoffl
Comment Utility
opps - last one shouldhve been

Response.Write("From: " & Request.Form("whatever") & "<br>")
0
 
LVL 2

Expert Comment

by:turbosig
Comment Utility
can't you just insert a "<BR>"??
0
 
LVL 1

Expert Comment

by:russoffl
Comment Utility
If you are compliling a long string for the body of the email:

strBody = "From: " & Request.Form("whatever") & "<br>"
strBody = strBody & "Department: " & Request.FOrm("whatever_2") & "<br>"
strBody = strBody & "Detail: " ....etc, etc.
0
 
LVL 2

Accepted Solution

by:
MCM earned 80 total points
Comment Utility
if the email you are sending is not in HTML format, then you want an actual carriage return and line character, ie:


strBody = "From: " & Request.Form("whatever") & Chr(13) & Chr(10)
strBody = strBody & "Department: " & Request.FOrm ("whatever_2") & Chr(13) & Chr(10)
strBody = strBody & "Detail: " ....etc, etc.

or equivalently:

strBody = "From: " & Request.Form("whatever") & vbCrLf
strBody = strBody & "Department: " & Request.FOrm ("whatever_2") & vbCrLf
strBody = strBody & "Detail: " ....etc, etc.


 
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 17

Author Comment

by:Barry Cunney
Comment Utility
Hi Guys,
Below is very simple content of test mail.ASP I am trying:
Using <BR> but it does not seem to have any affect.
Just to keep things simple I am not requesting data from FORM, just assigning 2 strings to 2 variables and then trying to create body message with THESE 2 VARIABLES fname and lname on two different lines.
Should I be specifying a 'BodyFormat' for the mail message

objCDO.BodyFormat = ??


<HTML>
<HEAD>
<TITLE>Mail Test</TITLE>
</HEAD>
<BODY>

<%
Dim fname, lname
Dim objCDO

fname = "Willy"
lname = "Wonka"

Set objCDO = Server.CreateObject("CDONTS.NewMail")

objCDO.From = "test@test.com" 'That's me :)

objCDO.To = "bcunney@worldlinkits.com"
         
objCDO.Subject = "Submitted form data from my page"

objCDO.Body = "Name: " & fname & "<BR>" & lname

objCDO.Send

%>
0
 
LVL 2

Expert Comment

by:MCM
Comment Utility
BodyFormat=1 will do HTML, BodyFormat=0 is plain text, with HTML you use "<BR>", with plain text, vbCrLF.
0
 
LVL 2

Expert Comment

by:MCM
Comment Utility
oops, i got them backwards
0 is HTML, 1 is plain text only.
0
 
LVL 7

Expert Comment

by:John844
Comment Utility
you can add a vbCrLf where you want the line break.
0
 
LVL 17

Author Comment

by:Barry Cunney
Comment Utility
Thanks MCM
I used the vbCrLf option and set BodyFormat to plain text
and this has done the job.
I had tried Chr(13) before but this didn't seem to work.
Was not able to get <BR> and HTML bodyformat to work either.
But anyway Plaintext Bodyformat and vbCrLF has given desired result so I a fairly happy.

MANY Thanks


B Cunney
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now