Topic: Export error message Posted: 05 Feb 2009 at 7:55am
Dear Brian
When I run the book chapter 19 of the new book code for exporting to EMail, I get the following exception:
CrystalDecisions.CrystalReports.Engine.InvalidArgumentException was unhandled Message="Invalid export options." Source="CrystalDecisions.CrystalReports.Engine" StackTrace: at CrystalDecisions.CrystalReports.Engine.STACaller.Call() at CrystalDecisions.CrystalReports.Engine.MAPIMessage.Send() at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportStreamToMAPI(Stream stream, MicrosoftMailDestinationOptions options, String name) at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.ReportDocument.Export(ExportOptions options) at _19_Exporting.Form1.ExportToEmail(ReportDocument myReport, String MailTo, String CCList, String Subject, String Message, String UserName, String Password) in C:\Users\Chitemerere\Documents\Crystal Reports\Brian Bishoff\CRNET 2005 Book\Windows\VB\19 Exporting\19 Exporting\Form1.vb:line 103 at _19_Exporting.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Chitemerere\Documents\Crystal Reports\Brian Bishoff\CRNET 2005 Book\Windows\VB\19 Exporting\19 Exporting\Form1.vb:line 9 at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at _19_Exporting.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
The code breaks at the line: myReport.Export(myExportOptions)
what could be the problem and what is the solution?
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Posted: 05 Feb 2009 at 11:40am
Can you post your code? All the code listings in the book are from
sample apps that I built and all were tested prior to copying the code
over.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
I have realiazide that the code only works when your mail program, Microsoft Outlook is open. If it is not, that is when you get an exception. Should this be the case, i.e. you have to have your mail program open before you run the export code? But however, the file exported to my mail program is not a pdf but a text file which is unreadable.
Please find below the code i am using.
Public
Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
"crimbo@ecoweb.co.zw", "", "testing", "See if this works", "crimbo", "Hd82vp")
'ExportToExchange(myReport, "kdkd", "a", "b")
End Sub
Public Sub ExportToPdfRtfWord(ByVal Filename As String, ByRef myReport As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal UsePageRange As Boolean, ByVal FirstPageNumber As Integer, ByVal LastPageNumber As Integer)
Dim myExportOptions As New CrystalDecisions.Shared.ExportOptions
'Set the export to a disk file
End If
'Assign the formatting properties to the report and export it
myExportOptions.FormatOptions = myFormatOptions
myReport.Export(myExportOptions)
End Sub
Public Sub ExportToExcel(ByVal Filename As String, ByRef myReport As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal UseConstantColumnWidth As Boolean, ByVal ColumnWidth As Integer, ByVal UseColumnHeadings As Boolean)
Dim myExportOptions As New CrystalDecisions.Shared.ExportOptions
'Set the export to a disk file
'Assign the formatting properties to the report and export it
myExportOptions.FormatOptions = myFormatOptions
myReport.Export(myExportOptions)
End Sub
Public Sub ExportToHTML(ByVal HTMLBaseFolderName As String, ByVal Filename As String, ByRef myReport As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal EnableSeparatedPages As Boolean, ByVal HasPageNavigator As Boolean)
Dim myExportOptions As New CrystalDecisions.Shared.ExportOptions
'Set HTML specific formatting properties
'Assign the formatting properties to the report and export it
myExportOptions.FormatOptions = myOptions
myReport.Export(myExportOptions)
End Sub
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
End Sub
Public Sub ExportToEmail(ByVal myReport As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal MailTo As String, ByVal CCList As String, ByVal Subject As String, ByVal Message As String, ByVal UserName As String, ByVal Password As String)
'Set the destination type to Email
Dim myExportOptions As New CrystalDecisions.Shared.ExportOptions
Further to my last post, I find it strange, I ran the Chapter 19 code without may mail program being open and it worked with no exception messages!!! However, the chapter 19 report is attached as a txt document and when you open it, it is ureadable. What is going wrong?
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum