🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #2686

Wie kan mij helpen: pdf omzetten onder access vba en dan mailen

#2686
From: bart van deun
Date: Tue, 20 Apr 2004 07:59
72 lines
3266 bytes
Ik zit met een probleemke:
met  deze tool: http://ourworld.compuserve.com/homepages/attac-cg/
kan ik onder access vba met library's PDF files maken van reports en
verzenden via email, dit allemaal op de achtergrond.
Nu zou ik dit willen inbouwen in mijn access crm systeem maar de code die ik
meekreeg, daar kom ik niet goed aan uit, door gebrek aan vba ervaring...
Kan iemand mij zeggen wat te doen?

dit is de code om verschillende email adressen aan te doen met een omgezette
pdf file (van de software leverancier):
(ik krijg bvb. als foutmelding dat adReadOnly een niet geregistreerde
variabel is...)

Dim objPDF as PDFClass
Dim objMail as MailClass
Dim strCurFileName as String

Dim strBaseFileLocation as String
Dim lngReturn as Long

Dim conn as ADODB.Connection    '<- ADO
Dim rsReports as New ADODB.Recordset    '<- ADO
Const MAIL_SYS_CDO = -1
Const RECIPIENT_TO = 1
Const PDFENGINE_PDFWRITER =1


Set conn = CurrentProject.Connection   '<- ADO
rsReports.Open "Select DISTINCT CustomerID, EMail from qryRptOrders", conn,
adOpenStatic, adReadOnly   '<- ADO
strBaseFileLocation = "C:\Temp\"
Set objPDF = New PDFClass
Set objMail = New MailClass

Do Until rsReports.EOF  'End of File

strCurFileName = strBaseFileLocation & "Orders For " & rsReports!CustomerID
& ".pdf"
With objPDF
  .PDFEngine = PDFENGINE_PDFWRITER
  .ReportName = "rptOrders"
  .ReportWhere = "[CustomerID] = " & rsReports!CustomerID
  .OutputFile = strCurFileName
  .PrintImage
  .lngReturn = .Result
 End With

 If lngReturn = True Then <- PDF was output successfully
  With objMail

.MsgSubjectText = "Current Invoice"
   .MsgBodyText = "Attached is the current invoice for your account in PDF
format."
   .RecipientAdd rsReports!CustomerID, rsReports!Email, ,RECIPIENT_TO, False
   .AttachmentAdd strCurFileName, "Current Account Invoice.pdf"
   .MsgSaveCopy = True
   .SendMail MAIL_SYS_CDO
   .RecipientsReset <- get ready for the next mail item
   .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
Technical Details
Message-ID: <SL4hc.78678$rL4.5093403@phobos.telenet-ops.be>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!ecngs!feeder.ecngs.de!193.190.198.58.MISMATCH!aotearoa.belnet.be!news.belnet.be!ossa.telenet-ops.be!phobos.telenet-ops.be.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII
X-Google-Thread: fcea4,23a7ff3251958b7c,start
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2004-04-20 00:59:47 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!ecngs!feeder.ecngs.de!193.190.198.58.MISMATCH!aotearoa.belnet.be!news.belnet.be!ossa.telenet-ops.be!phobos.telenet-ops.be.POSTED!not-for-mail
Reply-To: "bart van deun" <vdb@pandora.be>
From: "bart van deun" <vdb@pandora.be>
Newsgroups: be.comp.programming
Subject: Wie kan mij helpen: pdf omzetten onder access vba en dan mailen
Lines: 74
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <SL4hc.78678$rL4.5093403@phobos.telenet-ops.be>
Date: Tue, 20 Apr 2004 07:59:46 GMT
NNTP-Posting-Host: 213.118.148.215
X-Complaints-To: abuse@telenet.be
X-Trace: phobos.telenet-ops.be 1082447986 213.118.148.215 (Tue, 20 Apr 2004 09:59:46 MEST)
NNTP-Posting-Date: Tue, 20 Apr 2004 09:59:46 MEST
Organization: Telenet Internet