I'm at my wits end ... why I'm I getting this error (Object Variable or With Block Variable Not Set)?
Private Sub Command415_Click()
On Error GoTo errhandlers:
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
Dim rs As Recordset
Dim customerEmail As String
Dim n As Integer
If oOutlook Is Nothing Then
Set oOutlook = New Outlook.Application
End If
Set omailitem = oOutlook.CreateItem(olMailItem)
With oEmailItem
Set rs = CurrentDb.OpenRecordset("Select * from tblOutbounds")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do Until rs.EOF
If IsNull(rs!EMail) Then
rs.MoveNext
Else
customerEmail = customerEmail & rs!EMail & ";"
.To = customerEmail
rs.MoveNext
End If
Loop
Else
MsgBox "No customers on the list"
End If
.CC = ""
.Subject = "Attached files"
For n = 0 To Me.List3.ListCount - 1
.Attachments.Add (Me.List3.ItemData
)
Next n
.Display
End With
Exit_errhandlers:
Exit Sub
errhandlers:
MsgBox Err.Description, vbCritical
Resume Exit_errhandlers:
End Sub
Private Sub Command415_Click()
On Error GoTo errhandlers:
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
Dim rs As Recordset
Dim customerEmail As String
Dim n As Integer
If oOutlook Is Nothing Then
Set oOutlook = New Outlook.Application
End If
Set omailitem = oOutlook.CreateItem(olMailItem)
With oEmailItem
Set rs = CurrentDb.OpenRecordset("Select * from tblOutbounds")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do Until rs.EOF
If IsNull(rs!EMail) Then
rs.MoveNext
Else
customerEmail = customerEmail & rs!EMail & ";"
.To = customerEmail
rs.MoveNext
End If
Loop
Else
MsgBox "No customers on the list"
End If
.CC = ""
.Subject = "Attached files"
For n = 0 To Me.List3.ListCount - 1
.Attachments.Add (Me.List3.ItemData

Next n
.Display
End With
Exit_errhandlers:
Exit Sub
errhandlers:
MsgBox Err.Description, vbCritical
Resume Exit_errhandlers:
End Sub