Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / October 2004

Tip: Looking for answers? Try searching our database.

Outlook plugin hangs when trying to access AddressEntry object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim Shirley - 25 Oct 2004 19:21 GMT
I'm attempting to access the entries in an Outlook user's contact list
from within an Outlook plugin in C# (using Visual Studio 2003 and
Outlook 2003).  The following block of code works correctly, until it
gets to the last line (attempting to cast one of the items from the
contact list into an AddressEntry object) and then it hangs:

Outlook.NameSpace outlookNS = new
Outlook.ApplicationClass().GetNamespace("MAPI");
Outlook.Items coll =
outlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Items;
MessageBox.Show("Got collection.  item count is " + coll.Count);
MessageBox.Show("First item uncast is " + coll.GetFirst());
MessageBox.Show("First item cast is " + ((Outlook.AddressEntry)
(coll.GetFirst())));

I've tried this on a couple of different machines using Outlook 2003,
but it hangs at the same spot on both.  (The message box saying "First
item cast is ..." never appears.)  Any ideas what's going on here?

Thanks!
Dmitry Streblechenko \(MVP\) - 25 Oct 2004 19:28 GMT
MAPIFolder.Items collection returns either Outlook.ContactItem or
Outlook.DistListItem objects, but never Outlook.AddressEntry object.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

> I'm attempting to access the entries in an Outlook user's contact list
> from within an Outlook plugin in C# (using Visual Studio 2003 and
[quoted text clipped - 5 lines]
> Outlook.ApplicationClass().GetNamespace("MAPI");
> Outlook.Items coll =

outlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Items;
> MessageBox.Show("Got collection.  item count is " + coll.Count);
> MessageBox.Show("First item uncast is " + coll.GetFirst());
[quoted text clipped - 6 lines]
>
> Thanks!
Dmitry Streblechenko \(MVP\) - 25 Oct 2004 19:55 GMT
Clarification: MAPIFolder.Items collection returns either
Outlook.ContactItem or  Outlook.DistListItem objects for the Contact
folders. For other folders it can be MailItem, TaskItem, etc.
As a rule of thumb, you should be checking the Class property (all Outlook
objects have that property) - for the contact items (ContactItem), it is 40.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

> MAPIFolder.Items collection returns either Outlook.ContactItem or
> Outlook.DistListItem objects, but never Outlook.AddressEntry object.
[quoted text clipped - 13 lines]
> > Outlook.ApplicationClass().GetNamespace("MAPI");
> > Outlook.Items coll =

outlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Items;
> > MessageBox.Show("Got collection.  item count is " + coll.Count);
> > MessageBox.Show("First item uncast is " + coll.GetFirst());
[quoted text clipped - 6 lines]
> >
> > Thanks!
Tim Shirley - 29 Oct 2004 15:56 GMT
Ah, stupid me..  That fixed it.  Thank you very much!!

> Clarification: MAPIFolder.Items collection returns either
> Outlook.ContactItem or  Outlook.DistListItem objects for the Contact
[quoted text clipped - 36 lines]
> > >
> > > Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.