Hey Everyone!
I have an email code that works but will not list the invoices that are due. I have a loop that looks at email address' and adds them to sToName line. I have a static message that will need to list the outstanding invoices at the end of the statement. That's where i'm having trouble.
So after the text " Please address the listed invoice number/numbers" I want a list of the invoices.
Any help, kick or nudge in the right direction would be great!
Thanks!
larry
I have an email code that works but will not list the invoices that are due. I have a loop that looks at email address' and adds them to sToName line. I have a static message that will need to list the outstanding invoices at the end of the statement. That's where i'm having trouble.
Code:
Private Sub cmdEmail_Click()
Dim MyDb As Database
Dim rsEmail As DAO.Recordset
Dim rsInvoice As DAO.Recordset
Dim sToName As String
Dim sSubject As String
Dim sMessageBody As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("SELECT tblContact.OrganizationID, tblContact.ContactName, tblEmail.PrimaryEmail, tblEmail.SecondaryEmail, tblEmail.ThirdEmail " & _
"FROM tblContact INNER JOIN tblEmail ON tblContact.ContactID = tblEmail.ContactID " & _
"Where (tblContact.OrganizationID) = " & Me.OrganizationID)
Set rsInvoice = MyDb.OpenRecordset("Select * From qInvoiceData WHERE [Company ID] = '" _
& Forms![frmMainEntry]![frmInvoiceData].Form![Company ID] & "'")
[COLOR=palegreen]'Every from here to the next comment works great[/COLOR]
With rsEmail
Do Until rsEmail.EOF
If IsNull(rsEmail!PrimaryEmail) = False Then
sToName = sToName & rsEmail!PrimaryEmail & ";"
End If
.MoveNext
Loop
sSubject = "Finances are due for " & Me.OrganizationName
sMessageBody = "Please address the listed invoice number/numbers. " & vbCrLf & _
"If you have received this communication in error, please provide the correct contact information for this request by reply email to sender." & vbCrLf & _
vbCrLf & _
"Please see list of invoices. " & vbCrLf
End With
'This part doesn't work...I'm trying to list off the invoices that are over due
With rsInvoice
Do Until rsInvoice.EOF
If IsNull(rsInvoice!Invoice) = True Then
sMessageBody = sMessageBody & rsInvoice!Invoice
End If
.MoveNext
Loop
End With
DoCmd.SendObject acSendNoObject, , , sToName, , , sSubject, sMessageBody, True, False
End Sub
So after the text " Please address the listed invoice number/numbers" I want a list of the invoices.
Any help, kick or nudge in the right direction would be great!

Thanks!
larry