 |
|
 |
|
Next: Interoperability: Can't seem to get a name from the address book
|
| Author |
Message |
External

Since: May 26, 2006 Posts: 16
|
(Msg. 1) Posted: Tue Jun 05, 2007 2:39 pm
Post subject: Problems with COM Archived from groups: microsoft>public>outlook>interop (more info?)
|
|
|
Hi
I posted a quesiton earlier, but it hasn't showed up in over an hour, so
I'll post again, this time with more info.
So I'm tring to access the Outlook 2003 Address book from VB.net (using
VS.net 2005). I get the list open just fine using a call to
objSession.AddressBook( ). However, once a name is selected, I get an error
that reads:
"Unable to cast COM object of type 'System.__ComObject' to interface type
"Microsoft.Office.Interop.Outlook.Recipients'. This operation failed because
the QuesryInterface call on the COM component for the interface with IID
'{0006303B-0000-0000-C000-000000000046}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE))."
According to older documentation I found for VBA, the AddressBook( )
function returns a Recipients object, but I'm not getting it back, even when
I explicitly try to cast the return using CType. Instead, I get the error
above. Can someone help me?
Here's my code:
Public Function AddressBook_Click(ByVal myChoice As String) As String
Dim objNS As Microsoft.Office.Interop.Outlook.NameSpace
Dim objSession As Object 'As MAPI.Session
Dim objRecipients As Microsoft.Office.Interop.Outlook.Recipients
objSession = CreateObject("MAPI.Session")
objSession.Logon(, , False, False)
objRecipients = objSession.AddressBook(, "Please select", True,
True, 1, "mychoice")
AddressBook_Click = objRecipients.Item(1).AddressEntry
End Function
Thanks for your help!
-Josh |
|
| Back to top |
|
 |  |
External

Since: Jun 27, 2007 Posts: 3
|
(Msg. 2) Posted: Wed Jun 27, 2007 11:14 am
Post subject: Re: Problems with COM [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
I guess there is problem with your code written here.
You should first create an object of Application and then using Session
property of application object, create the namespace object if you want to
this object otherwise you can always simply go for AppObj.Session
(....property list), then you can use AddressLists property to get the list
of all the recipients.
--
Regards,
Amit Bhandari
"Dewey" <Dewey.RemoveThis@discussions.microsoft.com> wrote in message
news:33B1D26E-6409-480F-8DCE-2F26ACAFDD8A@microsoft.com...
> Hi
> I posted a quesiton earlier, but it hasn't showed up in over an hour, so
> I'll post again, this time with more info.
> So I'm tring to access the Outlook 2003 Address book from VB.net (using
> VS.net 2005). I get the list open just fine using a call to
> objSession.AddressBook( ). However, once a name is selected, I get an
> error
> that reads:
>
>
> "Unable to cast COM object of type 'System.__ComObject' to interface type
> "Microsoft.Office.Interop.Outlook.Recipients'. This operation failed
> because
> the QuesryInterface call on the COM component for the interface with IID
> '{0006303B-0000-0000-C000-000000000046}' failed due to the following
> error:
> No such interface supported (Exception from HRESULT: 0x80004002
> (E_NOINTERFACE))."
>
>
> According to older documentation I found for VBA, the AddressBook( )
> function returns a Recipients object, but I'm not getting it back, even
> when
> I explicitly try to cast the return using CType. Instead, I get the error
> above. Can someone help me?
>
> Here's my code:
>
>
>
> Public Function AddressBook_Click(ByVal myChoice As String) As String
>
> Dim objNS As Microsoft.Office.Interop.Outlook.NameSpace
> Dim objSession As Object 'As MAPI.Session
>
> Dim objRecipients As Microsoft.Office.Interop.Outlook.Recipients
>
> objSession = CreateObject("MAPI.Session")
> objSession.Logon(, , False, False)
> objRecipients = objSession.AddressBook(, "Please select", True,
> True, 1, "mychoice")
>
> AddressBook_Click = objRecipients.Item(1).AddressEntry
>
> End Function
>
>
> Thanks for your help!
> -Josh |
|
| Back to top |
|
 |  |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|