none
AccessViolation Accessing Sender RRS feed

  • Question

  • I recieve an unhandled exception System.AccessViolationException at Microsoft.Office.Interup.Outlook._MailItem.get_Sender()

    This error occurs in my code when I perform the following:

    Outlook.ExchangeUser senderExchange = theMailMessage.Sender.GetExchangeUser();


    I am running the application while logged in with an administrative acocunt.  The account also has priveleges on the exchange server.

    This code is used on a development network with no problem.  I only have this issue on the staging network.  But, the account permissions are the same on both networks. 

    has anyone seen this or have any ideas what might cause it?

    Wednesday, February 13, 2013 8:36 PM

Answers

  • I performed a complete uninstall of office 2010 and reinstalled office 2010 and now the application is working as expected.
    • Marked as answer by Sun Down Thursday, February 14, 2013 4:57 PM
    Thursday, February 14, 2013 4:57 PM

All replies

  • 1. Do you check that MailItem.Sender is not null?

    2. Do you check that Sender.AddressEntryUserType == OlAddressEntryUserType.olExchangeUserAddressEntry?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!


    Wednesday, February 13, 2013 8:59 PM
  • In my code I do test if it is an exchange user address. 

    On the network where it is failing I am using an email that I created to ensure it is to me from me and through exchange. 

    I even tried using my non-administrative account.  When I do that, I don't get any error.  The code fails at a line prior when I am getting the sender's email:
    String senderEmail = _MailMessage.SenderEmailAddress

    No errors, just hits this line and breaks out of the method without proceeding and that causes an infinite loop.

    On my administrator account it can see the sender email address and confirms that it is an exchange account.  I just cannot access the information.

    I've tried removing all Outlook Addins to make sure I do not have any kind of conflict.

    I have not tried to see if Sender is null, I will put that code in and test it.  Although, since this is a controlled test.  I am sure that sender won't be null.

    This same code is working on another network (processed over 30,000 emails yesterday), which leads me to believe it is more network / permission  specific.  But, unfortunatley the error doesn't really help me find the cause. 

    Thursday, February 14, 2013 1:13 PM
  • I also created a test:

    if(theMailMessage.Sender == null)
    {
    ...
    }

    the IF statement causes the error mentioned above.   I just cannot access the Sender object.

    I am currently asking the network admins to go over the permissions and see if they can find any discrepncy between the two networks that could cause this.

    Thursday, February 14, 2013 2:37 PM
  • I performed a complete uninstall of office 2010 and reinstalled office 2010 and now the application is working as expected.
    • Marked as answer by Sun Down Thursday, February 14, 2013 4:57 PM
    Thursday, February 14, 2013 4:57 PM