Email not including all the fields in the body text (1 Viewer)

Zampa

New member
Local time
Today, 17:17
Joined
May 21, 2019
Messages
8
I found some example code for sending emails, either on here or a different forum, which is great. The messages come up, the email is generated and sent and the CRM (the destination) is populated with the new email.

The problem i have is that ONLY the last field,in the section "build the body of the email", in this case, Renewal Date, is included in the body text.

Whichever line of sbody I make the last one seems to be what is included.

Does anyone have any great ideas as to how i can ensure all the fields are included?
Thanks
**************************************
'If this is a hot lead send an email to CRM

If Me.YNHotLead = True Then

Dim sTo As String
Dim sCC As String
Dim sBCC As String
Dim sSub As String
Dim sBody As String
Dim strCC As String
Dim OutApp As Object
Dim OutMail As Object
Dim varPress As Variant

strMess = "You are about to submit a message to the CRM" & vbCrLf & vbCrLf
strMess = strMess & "Do you wish to continue?"

strStyle = vbYesNo
strTitle = "Send to CRM"

varPress = MsgBox(strMess, strStyle, strTitle)
If varPress = vbYes Then
' Get the email address from the current form control

sTo = "crm@ourcompany.co.uk"

' Set the subject
sSub = "!!!!!New Hot Lead Submitted!!!!!!"

' Build the body of the email
sBody = Me.txtNotes & vbCrLf & vbCrLf
sBody = sBody & "Continue with message"
sBody = "Name =" & Me.txtName
sBody = "Products =" & Me.cboProducts
sBody = "OGI Ref =" & Me.txtOGIRef
sBody = "Phone Number =" & Me.txtMobile
sBody = "Renewal Date=" & Me.dtmRnlDate



' Create the email
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

sCC = ""
sBCC = ""


With OutMail
.To = sTo
.CC = sCC
.BCC = sBCC
.Subject = sSub
.Body = sBody
'.Display ' THis will display the email, but not send it
.Send ' THis will send the email
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 12:17
Joined
Apr 27, 2015
Messages
6,341
Your code should read "sBody = sBody & whatever & vbCrLf.
 

Zampa

New member
Local time
Today, 17:17
Joined
May 21, 2019
Messages
8
Thanks both - all sorted and working exactly as hoped for.
 

Users who are viewing this thread

Top Bottom