Symptom
- The export to MAPI code provided under the "Reproducing the Issue" heading works for 32 bit Microsoft Mail
- The same code when exporting to 64 bit Microsoft Mail produces the following error:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at CrystalDecisions.CrystalReports.Engine.STACaller.Call()
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 Unmanaged_RAS10_CSharp_Printers.frmMain.Export_Click(Object sender, EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Environment
- Crystal Reports for Visual Studio 2010 (64 bit runtime)
- Visual Studio 2010
Reproducing the Issue
- Using Crystal Reports for Visual Studio 2010 (CRVS2010)
- Use the code as described below
- Compile application as 64 bit or "Any CPU"
- Deploy the application using CRVS2010 64 bit runtime to a 64 bit Operating System with 64 bit Microsoft Outlook 64 bit installed
- Code:
private void Export_Click(object sender, EventArgs e)
{
CrystalDecisions.Shared.MicrosoftMailDestinationOptions mailOpts = CrystalDecisions.Shared.ExportOptions.CreateMicrosoftMailDestinationOptions();
CrystalDecisions.Shared.DiskFileDestinationOptions diskOpts = CrystalDecisions.Shared.ExportOptions.CreateDiskFileDestinationOptions();
CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
CrystalDecisions.Shared.PdfFormatOptions PDFExpOpts = new CrystalDecisions.Shared.PdfFormatOptions();
rpt.Load(@"c:\reports\World Sales Report.rpt");
PDFExpOpts.CreateBookmarksFromGroupTree = true;
PDFExpOpts.FirstPageNumber = 1;
PDFExpOpts.LastPageNumber = 1;
PDFExpOpts.UsePageRange = true;
// this gets the report name and sets the export name to be the same less the extension
string MyRptName = rpt.FileName.ToString();
MyRptName = MyRptName.Substring(MyRptName.LastIndexOf(@"\") + 1, (rpt.FileName.Length - 3) - (MyRptName.LastIndexOf(@"\") + 1)) + "pdf";
diskOpts.DiskFileName = MyRptName;
mailOpts.MailMessage = "See attached Action Plan";
mailOpts.MailSubject = "Action Plan";
mailOpts.MailToList = "yourmailaddress@msn.com";
mailOpts.Password = "YourMSNPassword";
exportOpts.ExportDestinationOptions = mailOpts;
exportOpts.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.MicrosoftMail;
exportOpts.ExportFormatOptions = PDFExpOpts;
exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
rpt.Export(exportOpts);
Cause
This issue is being tracked under problem ID ADAPT01603058.
Resolution
The issue is resolved in Service Pack 7 for SAP Crystal Reports, developer version for Microsoft Visual Studio
Keywords
CR2010 2010 CR4VS2010 CR4VS VS2010 NET2010 Crystal Reports for .NET Framework 4.0 crforvs 13 MicrosoftMail Office 10 2010 email mail e-mail mail microsoft , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , Bug Filed