View Full Version : Email problem


skwilliams
02-02-2004, 07:06 AM
I'm using some VBA code found in this forum for sending email to multiple recipient's listed in a table.

Here's the code:
Private Sub Shipping_Exit(Cancel As Integer)

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strEmail As String
Dim stDocName As String

stDocName = "rptNotShip"

Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset

rs.Open "tblNotShipEmail", cn

With rs
Do While Not .EOf
strEmail = strEmail & .Fields("Address") & ";"
.MoveNext
Loop
.Close
End With

strEmail = Left(strEmail, Len(strEmail) - 1)

DoCmd.SendObject acReport, stDocName, acFormatSNP, strEmail, , , "Daily Sales and Not Shipped Report", , False
End Sub

The problem is that I receive an error message that states "ActiveX component cannot create object". It refers to the line "Set cn = CurrentProject.Connection".

Any ideas??

Thanks.