I have read a number of posts and followed a number of dead-ends.
I am trying to export a Crystal report from a VB environment in VisualStudio 2012 to a Microsoft email client. I have read reports that the problem I am experiencing is probably due to MS no longer supporting a simple email export interface. I have installed CRforVS_13_0_5 and it is working fine in all other respects, but this email issue remains unresolved for me.
I have tried substituting an XP version of mapi32.dll into C:\Windows\SysWOW64 to no avail.
I have set up the mail and export options as follows:
Dim pdfOpts As PdfRtfWordFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions()
pdfOpts.UsePageRange = False
Dim exportOpts As New CrystalDecisions.Shared.ExportOptions
exportOpts = rptStatement.ExportOptions
exportOpts.ExportFormatOptions = pdfOpts
' Set the PDF format options.
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
exportOpts.ExportDestinationType = ExportDestinationType.MicrosoftMail
' Set the mail options.
Dim mailOpts As New CrystalDecisions.Shared.MicrosoftMailDestinationOptions
mailOpts.MailCCList = ""
mailstr = "Your Statement is attached as a PDF document"
mailOpts.MailMessage = mailstr
mailOpts.MailSubject = "test"
mailOpts.MailToList = emailadd
mailOpts.Password = officepw.Text '"fish4u" '"yucatan1"
mailOpts.UserName = "email@example.com"
exportOpts.ExportDestinationOptions = mailOpts
Catch ex As Exception
This the intractable error I receive:
System.AccessViolationException was caught
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
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 MF.CustStatement.sendemail_Click(Object sender, EventArgs e) in C:\Users\User\Documents\Visual Studio Projects\MFOff\CustStatement.vb:line 670
Any suggestions would be greatly appreciated.