PDA

View Full Version : VBA SELECT PLACE IN EMAIL



KDC900
02-28-2020, 06:17 PM
Hello my idea is to have a select statement get the info I needfor a list and then paste it into the body of an email. The problem I am havingis I get errors on the select statement such as “Syntax error” or “expectedcase”. Messing around with it I got it to open the email no problem but itpaste the code in the body instead of the results I am looking for. Below is mycode:


Private Sub Combo130_AfterUpdate()
Dim oLook As Object
Dim oMail As Object
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)

SELECT [All Years].ID, [All Years].[Last Name], [All Years].[First Name], [All Years].[Years of Service], [All Years].Department
FROM [All Years]
WHERE ((([All Years].Department) Like [Forms]![Print_Form]![Combo130]));

With oMail
.to = " "
.Subject = "Invite List"
.body = rs
.Display
End With

Set oMail = Nothing
Set oLook = Nothing
End Sub