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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling existing Crystal Report in VB.Net

Status
Not open for further replies.

Alkemac

IS-IT--Management
Jun 3, 2003
23
ZA
Hi.. am new to Vb.Net... Problem is, I have an exisiting report that I wish to call programatically, pass it two parameters and then email. Can someone please help ???

PS - Not for school project or any other nefarious reason!
 
Ok, I'm kinda new too but I think I can help.

First, call it programmatically use:

Dim MyReport as new (ReportName).rpt

//If ADO.net dataset is dataSource,
myReport.setDataSource(dataset)

//as for your parameters, you wnat just discrete values? I hope so, I haven't actually done this but apparently use can use formulas and it's much easier. Write the "formula" in the editor using crystal syntax then in the code write:

MyReport.DataDefinitons.FormulaFields("AField").Text="boobery"


//ok now e-mail, I don't know if I trust you with your "I'm not a badguy routine", but I'll help a little

MyReport.ExportOptions.ExportDestinationType = CrytalDecisions.Shared.ExportDestinationType.MicrosoftMail

Dim SendInfo as CrystalDecisions.MicrosoftMAilDestinationOptions = new cd.mmdo

//then set for options stuff like username,password, mail-to

//then set the options to your report property destinationOptions

myreport.exportOptions.DestinationOptions=SendInfo



That should be a good start, but don't go spamming reports to people!

 
Hi..I have been scouting around to find something to help me and came across the following if it is of some help to you....


Example
This example demonstrates how to use to set some of the properties of the MicrosoftMailDestinationOptions class.
[Visual Basic]
Public Sub ExportToMSMail(ByVal toList As String, ByVal subject As String, ByVal message As String, _
ByVal ccList As String, ByVal user As String, ByVal password As String)

' Declare variables and retrieve the export options.
Dim pdfOpts As PdfRtfWordFormatOptions = _
ExportOptions.CreatePdfRtfWordFormatOptions()
Dim mailOpts As MicrosoftMailDestinationOptions = _
ExportOptions.CreateMicrosoftMailDestinationOptions()
Dim exportOpts As ExportOptions = New ExportOptions

' Set the PDF format options.
pdfOpts.UsePageRange = False
exportOpts.ExportFormatOptions = pdfOpts

' Set the mail options.
mailOpts.MailCCList = ccList
mailOpts.MailMessage = message
mailOpts.MailSubject = subject
mailOpts.MailToList = toList
mailOpts.Password = password
mailOpts.UserName = user
exportOpts.ExportDestinationOptions = mailOpts

' Export the report.
exportOpts.ExportDestinationType = _
ExportDestinationType.MicrosoftMail
exportOpts.ExportFormatType = _
ExportFormatType.PortableDocFormat

Report.Export(exportOpts)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top