2121350 - Exporting to MAPI without Outlook running generates an error: Access Violation attempted to read write protected memory

SAP Knowledge Base Article - Public

2121350 - Exporting to MAPI without Outlook running generates an error: Access Violation attempted to read write protected memory

Symptom

Problem statement:

We are facing an error regarding with Crystal Report for Visual Studio. We have an application which can send invoices to e-mail. When we do export the Crystal Report we are getting following error for some clients.

Crystal Reports Error description:

  1. Error: crystal report error external component has thrown an exception.
  2. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  3. Error: Invalid export options Exception Description:

 

Environment

Crystal Report for Visual Studio

Outlook 2010 or 2013

Cause

The error may happen also if IE 11 is started and then closed or if Outlook is closed while the export is happening. IE 11 has a WEB interface to MAPI for Mail.

Resolution

CR for VS .NET has always required Outlook to be running when exporting to MAPI as the destination.

After a quick search on the WEB for sample code on how to detect if Outlook is running here is an example of how to:

bool msOutlook = false;
foreach (Process otlk in Process.GetProcesses())
{
    if (otlk.ProcessName.Contains("OUTLOOK"))
    {
        msOutlook = true;
    }
}
if (msOutlook.Equals(true))
{
    TextboxForMessages.Text = "Outlook is running";
}
else
{
    MessageBox.Show("Outlook needs to be running to send email - starting it now. Then resend your export", "Mail error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    System.Diagnostics.Process.Start("OUTLOOK.EXE");
    return;
}

Keywords

Crystal Report for Visual Studio, Outlook, Access Violation, read write protected memory , KBA , BI-RA-CR-SDK , SDK related, including Java/.NET etc. , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2005 ; SAP Crystal Reports, version for Visual Studio .NET 2008