can a code written for outlook 2010 work with outlook 2003

162 Views Asked by At

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.

1

There are 1 best solutions below

0
meir On

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

}