View Single Post
  #8  
Old March 24th 10, 10:55 AM posted to microsoft.public.outlook.program_vba
Andrei Smolin [Add-in Express][_2_]
external usenet poster
 
Posts: 5
Default Iterating a Contacts folder for Outlook 2003 and 2007 in C#

Hi Bob,

Using Outlook;


Add-in Express provides version-neutral interops. In your case the interops
are for Outlook 2000 and Office 2000 (common tools). The namespaces
contained in these interops are Outlook and Office, respectively.

Using Outlook1 = Microsoft.Office.Interop.Outlook;


This statement refers to PIA for some Outlook version; it may be Outlook
2002, 2003 or 2007.
[i]
c = (Outlook.ContactItem)items;


Yes, this is a kind of restriction in version-neutral interops. Try c =
items.Item(i) as Outlook.ContactItem;

Also, you may want to read my post at the Add-in Express blog on how to
support several Outlook versions in a COM add-in using different interop
versions via early and late binding, see
http://www.add-in-express.com/creati...-late-binding/.

I am a rare visitor here. If you have any questions you can quickly reach me
on our forums, see http://www.add-in-express.com/forum/index.php.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
www.add-in-express.com


"Marketware" wrote in message
news[i]
It appears as if I've got some weird "Using Statements" One that's just

Using Outlook;

and other,

Using Outlook1 = Microsoft.Office.Interop.Outlook;

And the original DLL on the above did not allow the "foreach". I found
another DLL which does allow it, and it seemed to work with both 2003 and
2007 so I think I may be OK with that. But do you know what the first one
is
pointing to? If I remove it I get a bunch of errors in the stuff you
wrote
for us.


"Marketware" wrote:

I am using the code you wrote to instaniate an Outlook object. I'm going
to
create a new project (separate out just this code) into a new project and
see
if I can see anything.

bob

"Ken Slovak - [MVP - Outlook]" wrote:

No idea, that is very bizarre.

I use that type of code all the time. It compiles perfectly here. In
fact, I
copied it from a working project I was just compiling.

I just tested and compiled again, and it compiled again with no errors.
There's some other problem that you have.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Marketware" wrote in message
news Now I have a new compiler problem. On the line:

c = (Outlook.ContactItem)items;

I get the following:

Cannot apply indexing with [] to an expression of type
'Outlook.Items'

I've also tried to replace with () and I get another error about
trying to
use as a method.

Ideas??

.


Ads