Add CrLf to a string of text

I am writing lines of text to an .ini file. See below:

    a.WriteLine ("Email text= Dear " & strfirstname & ", " & _
    "Your quote has been attached to this e-mail. Thank you for allowing " & rs("Name") & " the opportunity " & _
    "to provide this quotation. Please call us for any of your QUALITY label needs.")

But I need to put a CrLf between each sentence. I tried using vbCrLf but got errors when I tried to save it. How can I embed code to produce a CfLf between each line???????
sclarknyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Chr(13) & Chr(10)

mx
0
chikenheadCommented:
char(10) & char(13)
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"Sentence ... " Chr(13) & Chr(10) & "Another Sentence ..." Chr(13) & Chr(10) ....

mx
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

zwseemmCommented:
chr(13) is what you use  


 a.WriteLine ("Email text= Dear " & strfirstname & ", " & chr(13) &_
    "Your quote has been attached to this e-mail. Thank you for allowing " & rs("Name") & " the opportunity " & chr(13) & _
    "to provide this quotation. Please call us for any of your QUALITY label needs.")
0
Ashish PatelCommented:
writeline itself adds a vbCrLf at the end, so writing in 3 lines can be used like this.




a.WriteLine ("Email text= Dear " & strfirstname & ", " & _
    "Your quote has been attached to this e-mail.")
a.WriteLine ("Thank you for allowing " & rs("Name") & " the opportunity " & _
    "to provide this quotation.")
a.WriteLine ("Please call us for any of your QUALITY label needs.")

Open in new window

0
sclarknyAuthor Commented:
When I added in the chr(13) and chr(10) :
    a.WriteLine ("Email text=Dear " & strfirstname & ", " & Chr(13) & Chr(10) & "Your quote has been attached to this e-mail.")
 This is going into the body of an email. When I changed the code as above I only saw the following:

Dear Customer,              nothing else was visible.....................
0
sclarknyAuthor Commented:
I will try that asvforce
0
TextReportCommented:
Are you sure the INI file will handle a CR LF, normally the INI settings are single lines. Have you tried setting this manually in th INI

The vbCrLf (Chr(13) & Chr(10)) has to outside your quotes but you may also need to check vbCr (Chr(13))

Cheers, Andrew
0
dqmqCommented:
Slightly more elegant  to use the constant vbNewLine than the hardcoded ascii codes.  Gives you more portabilty over platforms and codesets.  I know--chr(10) and chr(13) are about as standard/stable as they get.  
0
Ashish PatelCommented:
by the way sclarkny: if the text is going in the body of an email, then make sure that the email format type is Text and if it is HTML Type then you will have to use <BR> for breaking lines.

So, if the email format type is HTML then use the below and should work good

a.WriteLine ("Email text= Dear " & strfirstname & ", " & _
    "Your quote has been attached to this e-mail. <br>Thank you for allowing " & rs("Name") & " the opportunity " & _
    "to provide this quotation. <br>Please call us for any of your QUALITY label needs.")
0
sclarknyAuthor Commented:
asvforce

I changed the code see below

    a.WriteLine ("Email text=Dear " & strfirstname & ", ")
    a.WriteLine ("Your quote has been attached to this e-mail.")

but I still only see the first line in the body of the email............If I put the second line on the end of the first line I see it all       like this

a.WriteLine ("Email text=Dear " & strfirstname & ", " & "Your quote has been attached to this e-mail.")

but can't use any carriage control/line feeds.One line runs into the other.
0
Ashish PatelCommented:
can you please try this

a.WriteLine ("Email text= Dear " & strfirstname & ", " & _
    "<br>Your quote has been attached to this e-mail. <br>Thank you for allowing " & rs("Name") & " the opportunity " & _
    "to provide this quotation. <br>Please call us for any of your QUALITY label needs.")

0
TextReportCommented:
Are you sure the INI file will handle a CR LF, normally the INI settings are single lines.

If this is HTML text you can try </P> (I Think)

Cheers, Andrew
0
zwseemmCommented:
Did you try just tje chr(13) code that I posted?
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
If it's HTML then use
<br>

which is a line feed / cr

mx
0
TextReportCommented:
I wasn't sure when I said </P> I think I mixed it up with MS Word Search for Paragraph Marger /P
Cheers, Andrew
0
sclarknyAuthor Commented:
asvforce

   I tried your suggestion and I now se the following
;Dear Marc, <br>Your quote has been attached to this e-mail. <br>Thank you for allowing Precision Label Corporation the opportunity to provide this quotation. <br>Please call us for any of your QUALITY label needs.

  btw..........the email is plain text
0
sclarknyAuthor Commented:
TextReport

  I am putting all of the text in a single line but can't get the LF CR to format the message once I put it in the body of the email.
0
TextReportCommented:
The Chr(13) & Chr(10) or vbCrLf will put a carridge return and lione feed into the INI file not into the email. You need to check with the software you are using (whose INI file it is) to see if there is an acceptable characher of group of characters that can be used to enter the CRLF.

As I have said earlier "Are you sure the INI file will handle a CR LF, normally the INI settings are single lines."

Please advise what you are using to produce your email.

Cheers, Andrew
0
sclarknyAuthor Commented:
I am using pdfedit995 from software995 to create the email
0
TextReportCommented:
In PDFEdit995 you need to set Email text= in the INI file and create the message body in c:\pdf995\res\utilities\email.txt

Taken from the PDFEdit995 help page

1: Autolaunch
When Autolaunch is checked, pdf995 will automatically display PDF documents in the default PDF viewer when printing is complete. This requires that a PDF viewer is installed.

When Auto-Email is checked, pdf995 will automatically attach a PDF to an email message for sending. This requires that a default MAPI compliant email client such as Microsoft Outlook is specified.

Adding the following to the Parameters section of pdf995.ini will allow you to specify a recipient, text and a subject.

Email Subject=hello world
Email Recipient Address=support@pdf995.com
Email Recipient Name=Pdf995 Support
Email text=this is the text

Auto-Email can also be configured to send via SMTP directly without requiring user input and without displaying the email message. The following parameters are required:

SMTP=1
Email Subject=
Email Recipient Address=
Email Server=
Email Password=
Email From Address=
Email text=

In both cases, if the entry Email text entry is omitted, the message text may be specified in c:\pdf995\res\utilities\email.txt

Cheers, Andrew

Sub Example_CreateTxtFile()
Dim strFileName As String
Dim ff As Long
Dim strData As String
Dim aryData
Dim cnt As Long
 
    strFileName = "c:\pdf995\res\utilities\email.txt"
    If Dir(strFileName) <> "" Then Kill strFileName
    
    ff = FreeFile
    
    Open strFileName For Output As #ff
    Print #1, Chr(34) & "ID" & Chr(34) & "," & Chr(34) & "Description" & Chr(34)
    Print #1, "1," & Chr(34) & "Hello" & Chr(34)
    Print #1, "2," & Chr(34) & "World" & Chr(34)
    Print #1, "3," & Chr(34) & "OK" & Chr(34)
    Close #ff
 
 
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sclarknyAuthor Commented:
Worked GREAT!!!!!!!!!!!!!!!!!!! exactly what I was looking for..............

I didn't know about the email.txt file........thanks for the solution.............
0
TextReportCommented:
I am intrigued to know why you are using PDFEdit995 to send the email rather than outlook or SMTP. This is the first time I have come across it. I have used PDFEdit995 and hte rest of the suite quite a lot but never thought of sending emails.
Cheers, Andrew
0
sclarknyAuthor Commented:
The original task was to create a PDF and email it. But I was getting various security warnings from Outlook. Using PDFEdit995 allowed me to avoid them.  Besides it was esay to configure and execute from access. And I didn't want to install other 3rd party software to get me around the security warnings. And I wasn't sure if there was a way to send it using SMTP. I didn't setup this server and they are using a 3rd party exchange server for email. This software was well worth the license fee.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.