Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / December 2004

Tip: Looking for answers? Try searching our database.

How can I get DefaultFolder by means of InvokeMember?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pino - 17 Dec 2004 14:36 GMT
I'm posting here because there's not a newsgroup about reflection and my
issue is about a COM application: Outlook 2003.

I'm using the following code (I'm referring Outlook and using Reflection in
VS2003):

Type otype = Type.GetTypeFromProgID("Outlook.Application",true);
object outlook = Activator.CreateInstance(otype);
object ns =
otype.InvokeMember("GetNamespace",BindingFlags.InvokeMethod,null,outlook,new
object[]{"MAPI"});
object df =
otype.InvokeMember("GetDefaultFolder",BindingFlags.InvokeMethod,null,ns,new
object[]{Outlook.OlDefaultFolders.olFolderContacts});

The last statement fails, and the exception message is:"Object does not
match target type."

Can anyone help me? What's wrong?
TIA
Pino
Phil Wilson - 17 Dec 2004 15:18 GMT
Doesn't GetDefaultFolder belong to the namespace interface? You're still
using otype.
Signature

Phil Wilson
[Microsoft MVP-Windows Installer]

> I'm posting here because there's not a newsgroup about reflection and my
> issue is about a COM application: Outlook 2003.
[quoted text clipped - 17 lines]
> TIA
> Pino
Pino - 22 Dec 2004 17:07 GMT
Yes, it's true, InvokeMember is called above otype.
I referred Namespace in the 4th parameter of InvokeMember (see: ns)
Haven't I to call InvokeMember on the type of the COM object? I think yes.

Pino

> Doesn't GetDefaultFolder belong to the namespace interface? You're still
> using otype.
[quoted text clipped - 19 lines]
>> TIA
>> Pino

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
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.