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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chr(13) = Carriage Return not working in email 1

Status
Not open for further replies.

Roosters

Technical User
May 14, 2000
61
AU
Hi,

First of all I'm only a part time user of Access code and would be in huge trouble if not for the help received from you guys here :)
My latest problem is with building an email and sending it to Lotus Notes, in short my code is as follows

Private Sub cboSendEmail_Click()
Dim strEmail, strBody, strSubject As String

strBody = strBody & "Dear " & txtName & Chr(13) & Chr(13)
strBody = strBody & "Below is the information you requested" & Chr(13) & Chr(13) & Chr(13)
strBody = strBody & "Name: " & txtSNO & Chr(13)
strBody = strBody & "Date: " & txtSNO & Chr(13)
strBody = strBody & "City, State, Zip: " & txtAddress & Chr(13)
strBody = strBody & "Outage Area: " & txtArea & Chr(13)
strBody = strBody & "Incident Number: " & txtINCD & Chr(13)
strBody = strBody & "Fault: " & txtFault & Chr(13)
strBody = strBody & "Outage Time" & txtTime

DoCmd.SendObject acSendNoObject, , "Rich Text Format", strEmail, , , strSubject, strBody

End Sub


This works fine, as in it fills in all relevant fields in the email but the strBody text loses the Chr(13) = Carriage Return function and all the text is bunched up in one continuious line.

If I substitute the strEmail with the strBody string the text retains the Chr(13) = Carriage Return within the "To." field of the email.

Any help would be appreciated

Phil
 
Chr(13) is only a half of what you need. Add also Chr(10) - line feed. Or you can use what VulcanJedi suggests and have both in one: vbCrLF

I just use [tt]vbNewLine[/tt] instead. Easy to remember.

BTW, you do know that in VBA your line:[tt]
Dim strEmail, strBody, strSubject As String
[/tt]
translates to:[tt]
Dim strEmail As Variant, strBody As Variant, strSubject As String
[/tt]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Thanks guys,

The constant vbCrLF works a treat, problem solved, your relpies are much appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top