Desperately need help with PDF & Mail Library!

  • Thread starter LongWayFromHome
  • Start date
L

LongWayFromHome

I desperately need help implementing AGC's PDF and Mail Library. I only
partially understand the sample code on which I am trying to build my own. I
have not received a response from their tech support. If anyone out there
can guide me, I'd be grateful.

I need to create a PDF file of a report which is then attached to an Outlook
email and sent. The PDF creation is working flawlessly, but I am getting a
crash with the MailClass. All variations on .SendMail produce "Error: Email
System LogOn. Cannot initialize the selected mail system...".
(I am running this with Outlook launched & waiting.)

Here are some possibly pertinent details:

- PDF & Mail Library is installed on one workstation
- OS: Win 2000 Pro 5.00.2195 SP4
- Mail Client: Outlook 2003 (11.8002.6568) SP2
- Server: (I do not have the specs on this yet)
- MailClass.Result = -1
- The Redemption library has been installed, correctly I hope.
- Outlook was installed with the CDO Library, I'm told.

My available References include:
- AGC PDF and Mail Library
- MS Outlook 11.0 Obj Library
- SafeOutlook Library
- MS ActiveX Data Objects 2.6 Library

My code (based largely on their samples):

Private Sub PDFBttn_Click()
Dim objPDF As PDFClass
Dim strCurFileName As String
Dim strBaseFileLocation As String
Dim lngReturn As Long
Const PDFENGINE_WIN2PDF = 3
Dim conn As ADODB.Connection
Dim rsReports As New ADODB.Recordset
Dim strANDI As String
Dim strDonor As String
Dim strYear As String
Dim objMail As New MailClass
Dim Success As LongDim strEmail As String
'I HAVE TRIED BOTH OF THESE:
Const MAIL_SYS_OUTLOOK_EX = 1
Const MAIL_SYS_REDEMPTION = -2

Set conn = CurrentProject.Connection
rsReports.Open "Select DISTINCT...", conn, adOpenStatic, adLockReadOnly
'CREATE FOLDER FOR THE PDFs...
strYear = Forms!SWB!EndwRptFY
Set objPDF = New PDFClass
objPDF.PDFEngine = PDFENGINE_WIN2PDF
Do Until rsReports.EOF
'PDF PRINTS HERE...
'PDF IS SAVED HERE...
'EMAIL STARTS HERE...
strEmail = rsReports!DonEmailAddr
With objMail
..MsgSubjectText = "Your " & strYear & " Report"
..MsgBodyText = "Your " & strYear & " Report is attached."
..MsgSaveCopy = True
..RecipientInAddressBook = False
..RecipientMailAddress = strEmail
..RecipientAdd
..AttachmentAdd strCurFileName
'THE ERROR OCCURS WITH ALL OF THESE:
' .SendMail -2
' .SendMail MAIL_SYS_OUTLOOK = 0
' .SendMail MAIL_SYS_OUTLOOK_EX = 1
' .SendMail MAIL_SYS_OUTLOOK_REDEMPTION = 2
..RecipientsReset
..AttachmentsReset
End With
Success = objMail.Result
rsReports.MoveNext
Loop
rsReports.Close
Set objPDF = Nothing
Set objMail = Nothing
End Sub

Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top