VB.NET and GetSharedDefaultFolder Strange Behaviour

S

sme

Hi,

I am using Visual Studio .NET 2003 application in order to get access to a
shared folder's contacts. I have "Referenced" the COM library for Outlook
2003.
Below you may find a sample code that loops through a specific user's
contects.
The pronle is that from the 1000 contacts that are stored in the shared
folder I can get only say 200 of them. The remaining 800 failed to be casted
to ContactItem event though the type of these items are ContactItems.

I checked the Outlook version of these contact items but most of them are in
the same version as the other 200 that I can process.

Is it a problem of .NET Interop?

Any help on this would be very important in order to proceed with our project.

Dim oApp As Outlook.Application = CreateObject("Outlook.Application",
"localhost")

' Get NameSpace and Logon.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
oNS.Logon()

Dim outrecp As Outlook.Recipient

outrecp = oNS.CreateRecipient("ikr")
outrecp.Resolve()

' Get the first contact from the Contacts folder.
Dim cContacts As Outlook.MAPIFolder =
oNS.GetSharedDefaultFolder(outrecp, Outlook.OlDefaultFolders.olFolderContacts)
Dim oItems As Outlook.Items = cContacts.Items

Dim oCt As Outlook.ContactItem
Dim ic As Int32 = 0
Try

Dim xx As Object
xx = oItems.GetFirst()

While Not xx Is Nothing

Try
oCt = CType(xx, Outlook.ContactItem)
ic = ic + 1
Catch ex As Exception
' This fails even though the xx is of type ContactItem
Console.WriteLine(TypeName(xx))
oCt = Nothing
End Try

If Not oCt Is Nothing Then
' Display some common properties.
Console.WriteLine(oCt.FullName)
End If
xx = oItems.GetNext
End While

Console.WriteLine(ic)
Finally
oNS.Logoff()

' Clean up.
oApp = Nothing
oNS = Nothing
oItems = Nothing
oCt = Nothing

End Try
 
S

sme

I believed that for thw Gold Partners the posts would be answered with in two
days.
Are there any news on this problem ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top