Have a new problem, maybe someone can help. The query we pull for the emails has the email address and the number needed to be sent. Because we have multiple numbers per address I am just trying to get the test function to do the following. Take the email and loop through the recordset, adding each number to a string and then putting the string in the body of the email. Here is the test function I was able to piece together from the threads:
Sub test()
Dim strTo As String 'The sendee(s) Needs to be fully qualified address. Other names seperated by commas
Dim strSubject As String 'The subject of the mail. Can be "" if no subject needed
Dim strBody As String 'The main body text of the message. Use "" if no text is to be included.
Dim FirstFile As String 'If you are embedding files then this is the first one. Use "" if no files are to be sent
Dim SecondFile As String 'Add as many extra files as is needed, seperated by commas.
Dim ThirdFile As String 'And so on.
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim qry As QueryDef
Dim strCc As String
Dim strBcc As String
Set db = CurrentDb
' query extracting email addresses,
' or SQL statement to do the same
Set qry = db.QueryDefs("qryemail")
Set rec = qry.OpenRecordset()
strTo = rec!email
Dim strNumbers As String
Do Until rec.EOF
If rec!email = strTo Then
strAccounts = strNumbers & rec!BoardingNumber & ","
'create a comma seperated list of filenames
rec.MoveNext
End If
Loop
strSubject = "Boarding Data Request"
strBody = "The attached is the boarding numbers."
strBody = strBody & vbCrLf & strNumbers
strBody = strBody & vbCrLf & "You will then be able to import the data from the DB import menu"
FirstFile = ""
SecondFile = ""
ThirdFile = ""
SendNotesMail strTo, strSubject, strBody, FirstFile, SecondFile, ThirdFile
End Sub
The problem is that it keeps hanging up my machine, does anyone see the problem in the code?