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 / Interop / February 2004

Tip: Looking for answers? Try searching our database.

Redemption + get ID from Name in outlook contacts + .net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anushya - 19 Feb 2004 05:39 GMT
Hi
How to get the id of a name in contact items in outlook. How to do it
thru redemption in .net??
i tried the code below. but it shows the error. pls have a look at the
code

Microsoft.Office.Interop.Outlook.NameSpace oNs;
oNs = Connect.oApplication.GetNamespace("MAPI");

//it shows an error here - invalid cast exception
Redemption.AddressLists  rAddressLists = (Redemption.AddressLists)
oNs.AddressLists;

for (int intI=0; intI < rAddressLists.Count;intI++)
{
Redemption.AddressList rAddressList = rAddressLists.Item(intI);
MessageBox.Show(rAddressList.ID + " " + rAddressList.Name);
}

Thanks
Anushya
Dmitry Streblechenko \(MVP\) - 19 Feb 2004 16:56 GMT
You are casting Outlook.AddressLists object returned by
Namespace.AddressLIsts to Redemption.AddressLists, that is bound to fail.
To use Redemption.AddressLists object, simply create an instane of it, there
is nothing else to do.

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

> Hi
> How to get the id of a name in contact items in outlook. How to do it
[quoted text clipped - 17 lines]
> Thanks
> Anushya
Anushya - 21 Feb 2004 06:16 GMT
Hi
Thanks Dmitry.

But How to create an instance for addresslists, addresslist,
addressentries & addressentry in .net? i dont know how since  cannot
create the object straight by using new. When i tried new operator
found addressListInterface and addresslistClass. How shud i????

then tried by creating object and then cast to object type(as u
suggested to someone in a group). but i cannot move thru items as it
is not a collection, just an object.
            Microsoft.Office.Interop.Outlook.NameSpace oNs;
            oNs = Connect.oApplication.GetNamespace("MAPI");
            Object rals;
           Object ral;
            Object raes;
            Object rae;
            rals = oNs.AddressLists;
            MessageBox.Show(((Redemption.AddressLists)rals).Count.ToString());
            for(int intI=0;intI<((Redemption.AddressLists)rals).Count;i++)
            {
//here is the problem, since rals is an object, cannot access
                ral = rals(intI);
                raes = ((Redemption.AddressList)ral).AddressEntries;
                for(int intJ=1;intJ<((Redemption.AddressEntries)raes).Count;intJ++)
                {
//here is the problem, since raes is an object, cannot access
                    rae = raes(intJ);
                    MessageBox.Show(((Redemption.AddressEntry)rae).Address );
                    //((Redemption.AddressEntry)rae).Address
                }
            }

Or shud i go thru some other way like

rals = Activator.CreateComInstanceFrom("Interop.Redemption.dll","Redemption.AddressListsClass");

Even so how to access the properties and methods????
My main intention is to get the id for the name i give, by accessing
outlook contacts.
Pls let me know
Thx
Anushya

> You are casting Outlook.AddressLists object returned by
> Namespace.AddressLIsts to Redemption.AddressLists, that is bound to fail.
[quoted text clipped - 27 lines]
> > Thanks
> > Anushya
Dmitry Streblechenko \(MVP\) - 21 Feb 2004 07:13 GMT
Simply use new to create an instance of the Redemption.AddressLists object.
Or something like

Type t = Type.GetTypeFromProgID("Redemption.AddressLists");
Redemption.AddressLists rals = (Redemption.AddressLists)
Activator.CreateInstance(t);

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

> Hi
> Thanks Dmitry.
[quoted text clipped - 32 lines]
>
> rals =
Activator.CreateComInstanceFrom("Interop.Redemption.dll","Redemption.Address
ListsClass");

> Even so how to access the properties and methods????
> My main intention is to get the id for the name i give, by accessing
[quoted text clipped - 34 lines]
> > > Thanks
> > > Anushya
 
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



©2009 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.