Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-mail reports 1

Status
Not open for further replies.

JohnSouth

Programmer
Feb 20, 2001
4
0
0
GB
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.

Cheers

John South
JS Associates
Pangbourne UK
 
Hi John,

From Crystal you would do:-

File...
Print...
export...
select Rich Text Format (RTF)
select Application or Word for windows document

This will open the report with Word
You then mail from there using send to...

Geoff

Alternatively, if the email is local you could try saving directly to an Exchange Folder

 
John,

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!

Benjamin Scott
thename@mindless.com
 
Thanks for that Benjamin

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."

Any ideas

John South
JS Associates
Pangbourne UK
 
John,

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.

Benjamin Scott
thename@mindless.com
 
John,

To see Crystal Care Technical Support Article c2007114.
And my samle:

Dim crxApplication As New CRAXDRT.Application
Public Report As CRAXDRT.Report

Private Sub Form_load()
Unload Form1
Set Report = crxApplication.OpenReport("d:\Report.rpt", 1)
NewRpt = "C:\NewName.rpt"
Report.SaveAs NewRpt, cr80FileFormat
Report.PrintOut False
Set Report = crxApplication.OpenReport(NewRpt, 1)
Dim crxExportOption As CRAXDRT.ExportOptions
Report.ExportOptions.DestinationType = crEDTEMailMAPI
Report.ExportOptions.FormatType = crEFTRichText
Report.ExportOptions.MailToList = "shml@musa-motors.com"
Report.ExportOptions.MailSubject = "Bla,bla,bla”
Report.ExportOptions.MailMessage = "My report for you"
Report.Export False
Kill NewRpt

End Sub

Shamil Kozin
shml@musa-motors.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top