Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Losing chr(13) in STRING variable

Status
Not open for further replies.

JPMorgan

Programmer
Dec 10, 2001
25
US
I am struggling with loosing my carriage returns in my string variable. I am sending an e-mail and want the body to display:
1
2
3
Instead, the body displays:
123

I have tried loading my variable these ways:
TO = "who@what.com"
WHAT = "Something for review.."
BODY = "1" & vbnewline & "2" & vbnewline & "3"

TO = "who@what.com"
WHAT = "Something for review.."
BODY = "1" & chr(13) & "2" & chr(13) & "3"

gsystem.sendmail TO,WHAT,BODY


I check BODY in the immediate window all the way untill it is executed by RunShellExecute in the SendEmail Sub in my Class Module. It is displaying correctly until it hits this then it loses its carriage returns.

Any ideas would be helpful! Thanks. JPM


Here is my Class Module that I am calling:

Public Sub SendEmail(sTo As String, sSubject As String, sBody As String)
' ------------------------------------------------------------
'Scope: Public
'Purpose: Opens the default web browser's mail program with the To:,Subject, and body filled in.
'Required:
'sTo - the e-mail address to whom you are sending mail
'sSubject - the subject line of the e-mail
'sBody - You get the idea...
'Useage:
'SendEmail "who@what.com", "This is the subject", "Here is the BODY!"
'** User is able to add to the body of the email detailing other information.
' ------------------------------------------------------------

Dim sTopic As String
Dim sFile As String
Dim sParams As Variant
Dim sDirectory As Variant

sTopic = "Open"
sFile = "mailto:" & sTo & "&Subject=" & sSubject & "&Body=" & sBody
sParams = 0&
sDirectory = 0&

Call RunShellExecute(sTopic, sFile, sParams, sDirectory, SW_SHOWNORMAL)
End Sub

Public Sub RunShellExecute(sTopic As String, sFile As Variant, _
sParams As Variant, sDirectory As Variant, nShowCmd As Long)
' ---------------------------------------------------------------------
' This Public Sub is used to launch the default e-mail program and
' default Web Browser
' ---------------------------------------------------------------------

Dim hWndDesk As Long
Dim success As Long

' -------------------------------
' Executes the passed operation
' -------------------------------
success = ShellExecute(hWndDesk, sTopic, sFile, sParams, sDirectory, nShowCmd)
End Sub
 
try vbCrrLf Craig, mailto:sander@cogeco.ca

Si hoc legere scis, nimis eruditionis habes
 
Ooops Typo...

vbCrLf Craig, mailto:sander@cogeco.ca

Si hoc legere scis, nimis eruditionis habes
 
that's VBCRLF (just one "r" after the "c")
:)
 
Still no change. Losing the VBCRLF when importing into default e-mail editor.

Thanks though.
 
Just for fun, the html equivalent would be :
1 <br> 2 <br> 3 <br>

I haven't tested it, though if your email is using html body style....
 
Thought the same thing, but this didn't work either. I even tested it on both normal and html body style.

In both cases it would print 1 <br> 2 <br> 3 <br>
 
To make that work on an HTML body style it would have to look like

<html><body>1<br>2<br>3<br></body></html> Craig, mailto:sander@cogeco.ca

Si hoc legere scis, nimis eruditionis habes
 
This would be a terrific workaround, Craig, but not the preferred solution because half of the users don't have their e-mail body style set to HTML.

If I could set the body style for them then that would be the solution, otherwise I am still looking for a way to keep my carriage returns in my code.

Thanks for all your input, gentlemen.

 
How are your displaying the email? Often, MS Outlook as the default format set to RichText or HTML. Try setting it to plain text (Tools | Options | MailFormat)

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top