Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:24:30+00:00 2026-06-12T12:24:30+00:00

I’m using the Office interop API to open a .msg file saved from outlook,

  • 0

I’m using the Office interop API to open a .msg file saved from outlook, and to then show a reply window to allow the user to reply to it.

When running Office 2003, the OpenSharedItem(pathToMSGFile); call throws the following exception:

Unhandled Exception: System.AccessViolationException: Attempted to read or write
  protected memory. This is often an indication that other memory is corrupt.
  at Microsoft.Office.Interop.Outlook._NameSpace.OpenSharedItem(String Path)
  at OutlookTest.Program.Main(String[] args)

When running Office 2008, it works absolutely fine.

I’ve put together a small test case, the code is as follows:

static void Main(string[] args)
{
    try
    {
        Application app;
        string pathToMSGFile = "\\\\path\\to\\foobar.msg";

        if (args.Length > 0)
        {
            pathToMSGFile = args[0];
        }

        if (!File.Exists(pathToMSGFile))
        {
            Console.WriteLine("{0} does not exist.", pathToMSGFile);
            return;
        }

        Console.WriteLine("Opening {0}", pathToMSGFile);

        Type olType = Type.GetTypeFromProgID("Outlook.Application", false);

        app = Activator.CreateInstance(olType) as Application;

        MailItem fld = (MailItem)app.Session.OpenSharedItem(pathToMSGFile);

        _MailItem reply = fld.ReplyAll();
        reply.Save();
        reply.Display(false);

        Console.ReadKey();

        reply.Close(OlInspectorClose.olDiscard);
    }
    catch (System.Exception ex)
    {
        Console.WriteLine(ex.ToString());

        if (ex.InnerException != null)
        {
            Console.WriteLine(ex.InnerException.ToString());
        }
    }

    Console.ReadKey();
}

The application is targeted as .Net 4, using the Office12 interop library. Same happens regardless of whether its compiled for AnyCPU or x86.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:24:31+00:00Added an answer on June 12, 2026 at 12:24 pm

    I note that version 11 of the interop library does not contain an OpenSharedItem() method.

    It becomes available from version 12 onwards.

    It appears that this operation is unavailable on Office 11/2003 (at least not via that method call on any version of the interop lib).


    I’m not sure if this is suitable for your scenario, but I’ve had good success with the Outlook Redemption library.

    From What is Outlook Redemption?:

    Outlook Redemption works around limitations imposed by the Outlook Security Patch plus provides a number of objects and functions to work with properties and functionality not exposed through the Outlook object model.

    Redemption library also includes the RDO (Redemption Data Objects) family of objects that can function as a complete CDO 1.21 or Outlook Object Model replacement.

    It seems to circumvent some of these odd/inconsistent behaviours b/w different versions of Outlook (either by design or as a "side effect" of the original goal).

    If you’re otherwise familiar with CDO, you’ll be comfortable with RDO. But to be honest I don’t know how it "maps" to Microsoft.Office.Interop.Outlook.

    Refer http://www.dimastr.com/redemption/rdo/rdosession.htm

    The equivalent RDO function for Session.OpenSharedItem() is RDOSession.GetMessageFromMsgFile().

    NB I’m in no way affiliated with this product, other than I’ve used it on occasion! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a reasonable size flat file database of text documents mostly saved in
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.