Hello,
Check this code
Code:
Private Sub Mail_Click()
Sun ap As Outlook.Applying
Sun em Have Outlook.MailItem
Set ap = Outlook.Application
'Declare a variable ADO:
Sun des As New ADODB.Recordset
des.Open "email", CurrentProject.Connection
'On positions on the first record:
des.MoveFirst
'Until the last record is not achieved:
While Not des.EOF
'It displays the contents of fields and namePrénom em:
Set em = ap.CreateItem(olMailItem)
'Set myAttachments = em.Attachments
With em.To des =("E_mail")
.Subject = "Company"
If IsNull(des("your ID")) = False Then
.Attachments.Add (des("ID"))
End If
.Body = "This is a test. Please do not reply to this message.
.Display
'. Send
End With
'We're going on the following:
des.MoveNext
Wend
'is closed and it frees the variable
des.Close
Set baud = Nothing
End Sub
Bookmarks