-1

We have a code written for outlook 2010.

When we run it on a computer using outlook 2003, we get an error.

We are trying to resolve user names by using Outlook.namespace GetSelectNamesDialog function

and the following exception appears when outlook 2003 is installed:

Exception Info :System.accessviolationexception.

Stack:

at Microsoft.Office.Interop.Outlook._NameSpace.GetSelectNamesDialog()

Is there any way that our code will work for both 2010 and 2003?

for now, it works just for outlook 2010.

Community
  • 1
  • 1
meir
  • 1
  • 2
  • if you have used features of outlook 2010 not available in 2003, you may not be able to run it. But provide more details, specifics, code, error messages – Dexters Feb 23 '14 at 08:19
  • Which interop libraries are you using for Outlook? – Rowland Shaw Feb 23 '14 at 08:30
  • Im using microsoft.office.interop.outlook pia/office12. The exception info: system.accessviolationexception. its appear when i try to do ctrl+k to add users. – meir Feb 23 '14 at 08:53
  • We are trying to resolve user names by using outlook.namespace GetSelectNamesDialog and the following exception appears when outlook 2003 is installed: accessviolationexception. What can i do about it? – meir Feb 23 '14 at 12:53

1 Answers1

1

you can implement 2 classes. one for 2010 and the other for 2003. make an interface of OutlookExchange with 3 function :send,resolve and close. those 2 classes will Inheritance from OutlookExchange. you need to check what is the outlook version that installed in your computer explnation in the next link How to detect installed version of MS-Office? , and use the class according to the version like that:

public static OutlookCreator()

{


Microsoft.Office.Interop.Word.Application appVer = new Microsoft.Office.Interop.Word.Application();

string[] _appVer=appVer.Split('.');

int version=Int32.Parse(_appVer[0]);

OutlookExchange exchange=null;

//outlook 2003

if(version==11)

   exchange=new Outlook2003();

//outlook 2007 and newer

if(version>11)

   exchange=new Outlook2010();

return exchange

}
Community
  • 1
  • 1
meir
  • 11
  • 1