Dim olLook As Object
Dim olNewEmail As Object
Dim distro As String
Dim strSql As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
strSql = "SELECT TBL_DodacieListyMnozstvo.ID_dl, TBL_DodacieListyMnozstvo.ID_tov" & _
" FROM TBL_DodacieListyMnozstvo" & _
" WHERE (((TBL_DodacieListyMnozstvo.ID_dl)=[Forms]![F_DODACIE_LISTYnovy]![ID_dl]))"
Set rst = db.OpenRecordset("strSql", dbOpenDynaset)
Do While Not rst.EOF
distro = distro & ";" & rst.Fields("[ID_tov]")
rst.MoveNext
Loop
Set olLook = CreateObject("Outlook.Application")
Set olNewEmail = olLook.CreateItem(0)
With Me
'Body
strEmailText = "List of Goods sold to the client: " & distro & vbCrLf
End With
With olNewEmail 'Attach template
.Display
.Subject = strEmailSubject
.HTMLBody = strEmailText & olNewEmail.HTMLBody & strline
End With
End Sub