Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

19.10 Exporting to Exchange Folders

Exporting to Exchange Folders

Crystal Reports lets you export a report to an Exchange folder. Table 19-8 shows the properties that need to be set for this to work.

Table 19-8. ExchangeFolderDestinationOptions Properties.

Property Description
DestinationType The export destination type
FolderPath The path of the Exchange folder
Password The Exchange password
Profile The user profile for accessing the Exchange folder

Listing 19-5. Export a report to an Exchange folder.
[VB.NET]
Public Sub ExportToExchange(ByVal myReport As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal FolderPath As String, ByVal Password As String, ByVal Profile As String)
'Set the destination type to ExchangeFolder
Dim myExportOptions As New CrystalDecisions.Shared.ExportOptions
myExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.ExchangeFolder
myExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
'Instantiate an ExchangeFolder options object and set its properties
Dim myOptions As CrystalDecisions.Shared.ExchangeFolderDestinationOptions
myOptions = CrystalDecisions.Shared.ExportOptions.CreateExchangeFolderDestinationOptions()
myOptions.DestinationType = CrystalDecisions.Shared.ExchangeDestinationType.ExchangePostDocMessage
myOptions.FolderPath = FolderPath
myOptions.Password = Password
myOptions.Profile = Profile
myExportOptions.DestinationOptions = myOptions
myReport.Export(myExportOptions)
End Sub
[C#]
public void ExportToExchange(CrystalDecisions.CrystalReports.Engine.ReportDocument myReport, string FolderPath, string Password, string Profile)
{
//Set the destination type to ExchangeFolder
CrystalDecisions.Shared.ExportOptions myExportOptions = new CrystalDecisions.Shared.ExportOptions();
myExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.ExchangeFolder;
myExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
//Instantiate an ExchangeFolder options object and set its properties
CrystalDecisions.Shared.ExchangeFolderDestinationOptions myOptions;
myOptions = CrystalDecisions.Shared.ExportOptions.CreateExchangeFolderDestinationOptions();
myOptions.DestinationType = CrystalDecisions.Shared.ExchangeDestinationType.ExchangePostDocMessage;
myOptions.FolderPath = FolderPath;
myOptions.Password = Password;
myOptions.Profile = Profile;
myExportOptions.DestinationOptions = myOptions;
myReport.Export(myExportOptions);
}

This procedure sets the report object’s destination type to be ExchangeFolder. Then it creates a new options object and assigns the parameters to the appropriate properties. The last step assigns the options object to the DestinationOptions property of the report object and calls the Export() method.