Hi
Using VB6 and Crystal Report Engine 7 Object Library
I need to e-mail reports directly to a recipient whose address is available to the VB code.
Does anyone have a simple example of how this is done.
I do the same thing. You export the report and then work through Outlook (I'm assuming you use Outlook which is likely dumb of me).
Const FILE_NAME As String = EXPORT PATH AND FILENAME Const REPORT_NAME As String = YOUR REPORT PATH AND FILENAME Const RECIPIENT_ADDRESS As String = RECIPIENT'S ADDRESS
Dim crApp As New CRAXDRT.Application
Dim crReport As CRAXDRT.Report
Dim crExport As CRAXDRT.ExportOptions
Dim olApp As New Outlook.Application Dim olMsg As Outlook.MailItem Dim olRecipient As Outlook.Recipient Dim olAttach As Outlook.Attachment
'Export the report as an Excel workbook Set crReport = crApp.OpenReport(REPORT_NAME) Set crExport = crReport.ExportOptions With crExport
.DestinationType = crEDTDiskFile
.FormatType = crEFTExcel80
.DiskFileName = FILE_NAME End With
crReport.Export False
Set crExport = Nothing Set crReport = Nothing Set crApp = Nothing
'Mail the workbook Set olMsg = olApp.CreateItem(olMailItem) Set olRecip = olMsg.Recipients.Add(RECIPIENT_ADDRESS) Set olAttach = olMsg.Attachments.Add(FILE_NAME)
olMsg.Send Set olAttach = Nothing Set olRecip = Nothing Set olMsg = Nothing Set olApp = Nothing
That works for me. I haven't worked out the export to an Exchange folder directly from Crystal yet... I hope it helps! Good luck!
I can see that should work, but I don't see why I should not be able to set the Export DestinationType to crMAPI and sent the file directly. I can with a Crystal OCX control, but when I try with the Report Engine Libray I get various errors.
I need to use the Report Engine because I'm passing recordsets using Active Data and I don't see a way of doing this with the OCX.
This is the code I am using:
Dim crwExportOptions As ExportOptions
Set crwExportOptions = SCRReport.ExportOptions
With crwExportOptions
.FormatType = crEFTRichText
.DestinationType = crEDTEMailMAPI
.MailSubject = "From KVCD"
.MailMessage = "Report Enclosed"
.MailToList = "jsouth@cwc.net"
End With
Call SCRReport.Export(False)
and the current error I get is:
"Method 'Export' of object 'ICRReport' failed."
Have you tried using the ActiveX Designer Run Time? I've always had much more difficulty using the Report Engine... I encountered various errors when using the Report Engine but was able to pull it off seamlessly using the ActiveX library.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.