Here is a link to a commercially-oriented educational site that talks about loops and how to set them up.
Loops in VBA allow users to repeat the same code block multiple times until a specific point is attained or a given condition is met.
corporatefinanceinstitute.com
In overview for your case, you pick two points in your code. Point 1 is where you actually start to build the message. This will be AFTER the point where you create the Outlook app object but before you create the mail object. Point 2 is where you have just sent the completed message and are done with it, ready to start on the next message.
Before point 1 you set up your chosen loop starter syntax. After point 2 you set up your chosen loop repetition syntax. Since you are using data from a recordset, you might want to look at a loop that uses
Do While Not recordset.EOF which will repeat the loop as long as you have data. At point 2, two things happen - first, the
recordset.MoveNext and second, the
Loop statement that repeats the code enclosed by points 1 and 2. The .MoveNext and Loop must occur in the order as stated.
Always remember this: When you create an external app object (in this case, Outlook), you are also creating an internal link, in essence a control channel, between Access and the other object, but that other object is in a separate task due to the way Windows does things. That means that before you are done with this, you must tell your object to close itself down. Otherwise you will leave a "dangling" task for which the control connections are severed when Access exits. At this point the other process is uncontrolled. Oh, it won't DO anything, but it takes up memory and can lead to resource issues. The only way to clear dangling tasks is with Task Manager to find them, then do an End Process manually.
If, on the other hand, you reach the point in your code where the loop exits (because you hit the .EOF condition), that is Point 3 - where you do an
object.Quit command before exiting that code segment. Though it usually doesn't matter THAT much, that is also where you would do a
recordset.Close as a precaution. Some versions of Windows and of Access have rarely shown issues of dangling recordsets. It's a rare condition that depends on which version of SMB protocol you are running and whether "buffer leasing" is going on at the time. It's easier to just close the recordset and sidestep the question altogether.