OracleRenegade
Programmer
Hi,
I am using Access 97 (no choice here - so please don't recommend upgrading!) and attempting to send a report via e-mail in a loop using module code (see below)
All works okay EXCEPT when I set the last parameter to FALSE to not edit the e-mail before sending - then the result is a zero KB attachment, BUT, with all other things the same TRUE (edit the mail) works as it should...
Any ideas anyone??
Private Sub mailloop_Click()
On Error GoTo Err_mailloop_Click
Dim stDocName As String
Dim vEmailAddress As String
Dim accountsToMail As Integer
DoCmd.GoToRecord , "", acFirst
stDocName = "NHS Single Debtor Statement"
Rem DoCmd.SendObject acReport, "NHS Single Debtor Statement",
Rem acFormatXLS after NHS Single Debtor Statement
Let accountsToMail = DLookup("[Total]", "AccountsToMailCount", 1 = 1)
For i = 1 To accountsToMail
Let vEmailAddress = DLookup("[EmailAddress]", "LookupEmailAddress", 1 = 1)
DoCmd.SendObject acReport, "NHS Debtor Statements", acFormatXLS, vEmailAddress, , , "NHS Debtor Statement from Leeds Teaching Hospitals", "Please see attached", True
DoCmd.GoToRecord , "", acNext
Next i
DoCmd.GoToRecord , "", acFirst
Exit_mailloop_Click:
Exit Sub
Err_mailloop_Click:
MsgBox Err.Description
Resume Exit_mailloop_Click
End Sub
I am using Access 97 (no choice here - so please don't recommend upgrading!) and attempting to send a report via e-mail in a loop using module code (see below)
All works okay EXCEPT when I set the last parameter to FALSE to not edit the e-mail before sending - then the result is a zero KB attachment, BUT, with all other things the same TRUE (edit the mail) works as it should...
Any ideas anyone??
Private Sub mailloop_Click()
On Error GoTo Err_mailloop_Click
Dim stDocName As String
Dim vEmailAddress As String
Dim accountsToMail As Integer
DoCmd.GoToRecord , "", acFirst
stDocName = "NHS Single Debtor Statement"
Rem DoCmd.SendObject acReport, "NHS Single Debtor Statement",
Rem acFormatXLS after NHS Single Debtor Statement
Let accountsToMail = DLookup("[Total]", "AccountsToMailCount", 1 = 1)
For i = 1 To accountsToMail
Let vEmailAddress = DLookup("[EmailAddress]", "LookupEmailAddress", 1 = 1)
DoCmd.SendObject acReport, "NHS Debtor Statements", acFormatXLS, vEmailAddress, , , "NHS Debtor Statement from Leeds Teaching Hospitals", "Please see attached", True
DoCmd.GoToRecord , "", acNext
Next i
DoCmd.GoToRecord , "", acFirst
Exit_mailloop_Click:
Exit Sub
Err_mailloop_Click:
MsgBox Err.Description
Resume Exit_mailloop_Click
End Sub