Hi guys. I'm having trouble with the following code. Sometimes the emails do get sent and at other times they don't. There is no pattern to that problem. Also, is there any way to insure that empty reports do not get sent? I'm using Microsoft Outlook 2003 and my database is an MS Access 2000. I've noticed that there a lot of problems with SendObject action when there are more than 70 characters in the body of the email, however, in my case the body of the email is blank. What do you thing the problem is? Here is the code:
Thank you!
Valeriya
Code:
Private Sub Command72_Click()
On Error GoTo ErrorHandler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strMsg As String
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT Assignee.ID, Assignee.[E-mail Address] FROM Assignee")
While Not rst.EOF
DoCmd.OpenReport "Open Project Details", acViewPreview, , "[Project Lead]=" & rst.Fields(0)
DoCmd.SendObject acSendReport, "Open Project Details", acFormatSNP, rst.Fields(1), , , "Your Spinal Supply Chain Projects by Status", True, False
DoCmd.Close acReport, "Open Project Details", acSaveNo
rst.MoveNext
Wend
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub
ErrorHandler:
strMsg = "Error number is: " & Err.Number & vbCrLf
strMsg = strMsg & "Error message is: " & Err.Description & vbCrLf
strMsg = strMsg & "Error source is: " & Err.Source
MsgBox strMsg, vbOKOnly + vbCritical, "Error"
Resume Next
End Sub
Thank you!
Valeriya