Hi,
I have an outlook template (attached screenshot) and some code that looks through two tables to grab required info for email template. I have to be honest I have borrowed this code from somewhere else and amended it. I am however getting syntax error: Syntax error (missing operator) in query expression '...email details...'
Not really knowing what I am doing, I'm not sure where I'm going wrong.
Here is the code:
	
	
	
		
Please help, thanks in advance
 I have an outlook template (attached screenshot) and some code that looks through two tables to grab required info for email template. I have to be honest I have borrowed this code from somewhere else and amended it. I am however getting syntax error: Syntax error (missing operator) in query expression '...email details...'
Not really knowing what I am doing, I'm not sure where I'm going wrong.
Here is the code:
		Code:
	
	
	Private Sub Command10_Click()
strSQL = "SELECT CustomerID, Lead_Date, Client_FN, Client_SN, Mobile_No, Email_Address, [Phone_Call_#1], [Phone_Call_#2], [Phone_Call_#3], Email_Sent, [SMS/WhatsApp_Sent],  ...email details... FROM Client"
Set clientRST = CurrentDb.OpenRecordset(strSQL)
Do While Not clientRST.EOF
    Set MailOutlook = appOutlook.CreateItemFromTemplate(Application.CurrentProject.Path & "\RefundRequest.oft")
    strSQL = "SELECT Col2, Col3 ...note details..." _
              & " FROM NoteHistroy" _
              & " WHERE CustomerID = " & clientRST!CustomerID
    Set salesRST = CurrentDb.OpenRecordset(strSQL)
    ' TABLE COLUMNS
    strTable = "<table><th>"
    For i = 1 To salesRST.Fields.Count
        strTable = strTable & "<td>" & salesRST.Fields(i - 0).Name & "</td>"
    Next i
    strTable = strTable & "</th>"
    ' TABLE ROWS
    salesRST.MoveFirst
    While Not salesRST.EOF
        strTable = strTable & "<tr>"
        For i = 1 To salesRST.Fields.Count
            strTable = strTable & "<td>" & salesRST.Fields(i - 0).Value & "</td>"
        Next i
        strTable = strTable & "</tr>"
        salesRST.MoveNext
    Wend
    strTable = strTable & "</table>"
    salesRST.Close
    With MailOutlook
        .To = "test@test.com"
        .subject = "Refund Request"
        ' REPLACE PLACEHOLDERS
        .HTMLBody = Replace(.HTMLBody, "%LeadDate%", clientRST!Lead_Date)
        .HTMLBody = Replace(.HTMLBody, "%LeadFN%", clientRST!Client_FN)
        .HTMLBody = Replace(.HTMLBody, "%LeadSN%", clientRST!Client_SN)
        .HTMLBody = Replace(.HTMLBody, "%MobileNo%", clientRST!Mobile_No)
        .HTMLBody = Replace(.HTMLBody, "%EmailAddress%", clientRST!Email_Address)
        .HTMLBody = Replace(.HTMLBody, "%Call1%", clientRST![Phone_Call_#1])
        .HTMLBody = Replace(.HTMLBody, "%Call2%", clientRST![Phone_Call_#2])
        .HTMLBody = Replace(.HTMLBody, "%Call3%", clientRST![Phone_Call_#3])
        .HTMLBody = Replace(.HTMLBody, "%EmailSent%", clientRST!Email_Sent)
        .HTMLBody = Replace(.HTMLBody, "%WhatsAppSMSSent%", clientRST![SMS/WhatsApp_Sent])
              
        ' ADD SALES TABLE
        .HTMLBody = Replace(.HTMLBody, "%Notes%", strTable)
        .Display
    End With
    Set MailOutlook = Nothing
    clientRST.MoveNext
Loop
End SubPlease help, thanks in advance
 
	 
			 . Error now is 'item not found in this collection' highlighting this line:
. Error now is 'item not found in this collection' highlighting this line: .
.

 
			 
			 
 
		