Hi all
i use the code below (with the linkend "PDF and Mail Library from ATTAC Consulting Group)
Dim objPDF As PDFClass
Dim objMail As MailClass
Dim strCurFileName As String
Dim strBaseFileLocation As String
Dim lngReturn As Long
'Dim rsReports As Recordset '<- DAO recordset
'Comment out the line above and uncomment the two lines below when using ADO in A2000 and 2002
Dim conn As ADODB.Connection '<- ADO
Dim rsReports As New ADODB.Recordset '<- ADO
Const MAIL_SYS_OUTLOOK_EXP = 1
Const RECIPIENT_TO = 1
Const PDFENGINE_WIN2PDF = 3
'Set rsReports = CurrentDb.Openrecordset("Select DISTINCT CustomerID, EMail from qryRptOrders", dbOpenSnapshot) '<- DAO recordset
'Comment out the line above and uncomment the two lines below when using with ADO in A2000 and 2002
Set conn = kundendb '<- ADO
rsReports.Open "Select DISTINCT ID, EMail_re from Kunden", conn, adOpenStatic, adReadOnly '<- ADO
strBaseFileLocation = "C:\datenblaetter\"
Set objPDF = New PDFClass
Set objMail = New MailClass
Do Until rsReports.EOF 'End of File
strCurFileName = strBaseFileLocation & "Datenblatt_NT fuer " & rsReports!ID & ".pdf"
With objPDF
.PDFEngine = PDFENGINE_WIN2PDF
.ReportName = "Datenblatt_NT"
.ReportWhere = "[ID] = " & rsReports!ID
.OutputFile = strCurFileName
.PrintImage
lngReturn = .Return
End With
If lngReturn = True Then
With objMail
.MsgSubjectText = "Test"
.MsgBodyText = "TEST"
.RecipientAdd rsReports!ID, rsReports!Email_re, , RECIPIENT_TO, False
.AttachmentAdd strCurFileName, "Datenblatt.pdf"
.MsgSaveCopy = True
.SendMail MAIL_SYS_OUTLOOK_EXP
.RecipientsReset
.AttachmentsReset
End With
Else
MsgBox "Error!"
End If
rsReports.MoveNext
Loop
rsReports.Close
Set objPDF = Nothing
Set objMail = Nothing
'Copyright © 1997-2003 ATTAC Consulting Group
-------------------------------------------------------------
after i open the access frontend (which will take the datas from a SQL Server) --> the error "object required" appears and noting happens
the code above shoud generate a pdf for the customer and then send him this via Mail, but it doesn't work
any idea?
thanks in advance for your trouble
best regards
E.Altherr
i use the code below (with the linkend "PDF and Mail Library from ATTAC Consulting Group)
Dim objPDF As PDFClass
Dim objMail As MailClass
Dim strCurFileName As String
Dim strBaseFileLocation As String
Dim lngReturn As Long
'Dim rsReports As Recordset '<- DAO recordset
'Comment out the line above and uncomment the two lines below when using ADO in A2000 and 2002
Dim conn As ADODB.Connection '<- ADO
Dim rsReports As New ADODB.Recordset '<- ADO
Const MAIL_SYS_OUTLOOK_EXP = 1
Const RECIPIENT_TO = 1
Const PDFENGINE_WIN2PDF = 3
'Set rsReports = CurrentDb.Openrecordset("Select DISTINCT CustomerID, EMail from qryRptOrders", dbOpenSnapshot) '<- DAO recordset
'Comment out the line above and uncomment the two lines below when using with ADO in A2000 and 2002
Set conn = kundendb '<- ADO
rsReports.Open "Select DISTINCT ID, EMail_re from Kunden", conn, adOpenStatic, adReadOnly '<- ADO
strBaseFileLocation = "C:\datenblaetter\"
Set objPDF = New PDFClass
Set objMail = New MailClass
Do Until rsReports.EOF 'End of File
strCurFileName = strBaseFileLocation & "Datenblatt_NT fuer " & rsReports!ID & ".pdf"
With objPDF
.PDFEngine = PDFENGINE_WIN2PDF
.ReportName = "Datenblatt_NT"
.ReportWhere = "[ID] = " & rsReports!ID
.OutputFile = strCurFileName
.PrintImage
lngReturn = .Return
End With
If lngReturn = True Then
With objMail
.MsgSubjectText = "Test"
.MsgBodyText = "TEST"
.RecipientAdd rsReports!ID, rsReports!Email_re, , RECIPIENT_TO, False
.AttachmentAdd strCurFileName, "Datenblatt.pdf"
.MsgSaveCopy = True
.SendMail MAIL_SYS_OUTLOOK_EXP
.RecipientsReset
.AttachmentsReset
End With
Else
MsgBox "Error!"
End If
rsReports.MoveNext
Loop
rsReports.Close
Set objPDF = Nothing
Set objMail = Nothing
'Copyright © 1997-2003 ATTAC Consulting Group
-------------------------------------------------------------
after i open the access frontend (which will take the datas from a SQL Server) --> the error "object required" appears and noting happens
the code above shoud generate a pdf for the customer and then send him this via Mail, but it doesn't work
any idea?
thanks in advance for your trouble
best regards
E.Altherr