Discussion:
Outlook 2007 automation with VS.NET 2005
(too old to reply)
Mark Rae
2007-05-01 16:53:21 UTC
Permalink
Hi,

I'm trying to iterate through the contents of a folder in a pst file using
VS.NET 2005 + SP1 and Outlook 2007 running on 64-bit Vista Business.
Virtually all the examples on Google and MSDN seem to be on how to write
add-ins - I don't want to do that.

I did find this article:
http://msdn2.microsoft.com/en-us/library/aa432009.aspx which I'm following
as closely as I can, but am coming unstuck...

I've added a reference to the Microsoft Office 12.0 Object Library (shows in
Solution Explorer as Microsoft.Office.Core) and
Microsoft.Office.Interop.Outlook, and am using the following code:

using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook;

Outlook.ApplicationClass _app = new Outlook.ApplicationClass();

The code compiles OK, but the line Outlook.ApplicationClass _app = new
Outlook.ApplicationClass(); generates the following error:
"Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following error:
80080005."

As far as I can tell, this should work, but have I missed a reference
somewhere or is there something else I've forgotten?

Any assistance gratefully received.

Mark
Dannel Albert
2007-05-04 18:39:22 UTC
Permalink
Hi Mark,

I seem to be having the same problem. I just started to work with outlook from VS.NET 2005 SP1 and Outlook 2007 on Vista x64 (Ultimate) and I get the same error. It only happens when Outlook is already open, but the same error doesn't occur on Windows XP (x86). I haven't been able to test other platforms or versions of Vista, but I think it's safe to say it's either a security issue on Vista or a bug. I'm going to ask about it on msdn.
Hi,
I'm trying to iterate through the contents of a folder in a pst file using
VS.NET 2005 + SP1 and Outlook 2007 running on 64-bit Vista Business.
Virtually all the examples on Google and MSDN seem to be on how to write
add-ins - I don't want to do that.

I did find this article:
http://msdn2.microsoft.com/en-us/library/aa432009.aspx which I'm following
as closely as I can, but am coming unstuck...

I've added a reference to the Microsoft Office 12.0 Object Library (shows in
Solution Explorer as Microsoft.Office.Core) and
Microsoft.Office.Interop.Outlook, and am using the following code:

using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook;

Outlook.ApplicationClass _app = new Outlook.ApplicationClass();

The code compiles OK, but the line Outlook.ApplicationClass _app = new
Outlook.ApplicationClass(); generates the following error:
"Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following error:
80080005."

As far as I can tell, this should work, but have I missed a reference
somewhere or is there something else I've forgotten?

Any assistance gratefully received.

Mark



___
Newsgroups brought to you courtesy of www.dotnetjohn.com
Dannel Albert
2007-05-04 18:57:04 UTC
Permalink
Hi again Mark,

I think I know what the problem is. When you run Outlook on Vista x64 it runs in the 32-bit virtualized environment (forgive me if my terminology is incorrect, but I think you understand what I mean). If you're like me, your project settings in VS are probably set to build for "Any CPU". The problem arises when you run your app, built for Any CPU - running in 64-bit mode on your platform, tries to create the COM object via the interop. Even though it will spawn the same 32-bit version of Outlook, I don't think it can see that it is already running because the app was started in a different context. The workaround is to build your project to target x86. Hope that helps, at least temporarily.

Dannel
Hi,
I'm trying to iterate through the contents of a folder in a pst file using
VS.NET 2005 + SP1 and Outlook 2007 running on 64-bit Vista Business.
Virtually all the examples on Google and MSDN seem to be on how to write
add-ins - I don't want to do that.

I did find this article:
http://msdn2.microsoft.com/en-us/library/aa432009.aspx which I'm following
as closely as I can, but am coming unstuck...

I've added a reference to the Microsoft Office 12.0 Object Library (shows in
Solution Explorer as Microsoft.Office.Core) and
Microsoft.Office.Interop.Outlook, and am using the following code:

using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook;

Outlook.ApplicationClass _app = new Outlook.ApplicationClass();

The code compiles OK, but the line Outlook.ApplicationClass _app = new
Outlook.ApplicationClass(); generates the following error:
"Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following error:
80080005."

As far as I can tell, this should work, but have I missed a reference
somewhere or is there something else I've forgotten?

Any assistance gratefully received.

Mark



___
Newsgroups brought to you courtesy of www.dotnetjohn.com
Richard Rudie
2007-05-05 05:35:49 UTC
Permalink
Post by Dannel Albert
I think I know what the problem is. When you run Outlook on Vista x64 it
runs in the 32-bit virtualized environment .... The workaround is to
build your project to target x86. Hope that helps, at least temporarily.
I am getting the same 0x80080005 error running under 32-bit Vista. If
Outlook is running, that is. When Outlook is not running, the interop
works fine. Though maybe a bit slowly.

Changing from "Any CPU" to "x86" didn't have any effect for me.

In researching the problem via Google searches I found a Microsoft
Knowledge Base page (http://support.microsoft.com/kb/257757) saying
"These errors appear because the server-side code is running without a
user profile or the user identity that is specified for the launching
context does not have proper DCOM permissions." I didn't see anything
in there about how one might go about acquiring the proper DCOM
permissions, though.

Please keep us advised if you find out anything through MSDN.
Moiz
2007-05-17 05:34:38 UTC
Permalink
Please read the following article:

http://msdn2.microsoft.com/en-us/library/aa168454(office.11).aspx

Moiz
MCSD
Moiz
2007-05-17 05:35:56 UTC
Permalink
Please read the following article:

http://msdn2.microsoft.com/en-us/library/aa168454(office.11).aspx

Moiz
MCSD
Dhanji
2007-05-17 05:45:01 UTC
Permalink
seems helpful ....
Nate Finch
2007-05-21 15:17:35 UTC
Permalink
Hate to be negative, but a link to a hugely long page on "what's new
in Outlook 2003" is completely f'ing useless. If there is any
information about the solution for this problem on that page (which I
highly doubt), you should at least call out the specific part of the
page, instead of just linking to it and expecting us to somehow divine
what part is relevant. That page, by the way, is over 3 years old,
published before Outlook 2007, Vista, or Visual Studio 2005 were
available. So please, if you don't know the answer, don't post
useless links that just waste our time with totally irrelevant
information.
Post by Moiz
http://msdn2.microsoft.com/en-us/library/aa168454(office.11).aspx
Moiz
MCSD
Nate Finch
2007-05-21 15:05:27 UTC
Permalink
I was having the same problem, and just figured it out. Lemme guess,
you're running VS 2005 as an administrator, right? But you started
Outlook just by hitting the shortcut in the start menu? Outlook's not
running as an administrator, so when VS2005 tries to connect as an
admin, it fails because it's already running as a non-admin. Just
start Outlook as an admin, and your code will connect to it just
fine. I had run into this problem before when I would have my code
start up outlook automatically (headless) and then try to run outlook
to bring up the UI... the UI would never pop up... because I was
trying to bring up the UI as a non-admin, and the headless outlook was
running as an admin.

Hope this helps!

-Nate
Post by Mark Rae
Hi,
I'm trying to iterate through the contents of a folder in a pst file using
VS.NET 2005 + SP1 and Outlook 2007 running on 64-bit Vista Business.
Virtually all the examples on Google and MSDN seem to be on how to write
add-ins - I don't want to do that.
I did find this article:http://msdn2.microsoft.com/en-us/library/aa432009.aspxwhich I'm following
as closely as I can, but am coming unstuck...
I've added a reference to the Microsoft Office 12.0 Object Library (shows in
Solution Explorer as Microsoft.Office.Core) and
using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook;
Outlook.ApplicationClass_app = new Outlook.ApplicationClass();
The code compiles OK, but the line Outlook.ApplicationClass_app = new
"Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following error:80080005."
As far as I can tell, this should work, but have I missed a reference
somewhere or is there something else I've forgotten?
Any assistance gratefully received.
Mark
Mark Rae
2007-06-02 16:21:11 UTC
Permalink
Post by Nate Finch
I was having the same problem, and just figured it out. Lemme guess,
you're running VS 2005 as an administrator, right?
Yep - is that not the recommended way to run VS.NET 2005 on Vista...?
Post by Nate Finch
But you started Outlook just by hitting the shortcut in the start menu?
Correct.
Post by Nate Finch
Outlook's not running as an administrator, so when VS2005 tries to connect
as an
admin, it fails because it's already running as a non-admin. Just start
Outlook as an
admin, and your code will connect to it just fine.
Yep, that fixed it! I'd never have thought of that...
Post by Nate Finch
Hope this helps!
Thanks very much.
--
http://www.markrae.net
SvenC
2007-05-21 15:44:59 UTC
Permalink
Hi Mark,
Post by Mark Rae
Hi,
I'm trying to iterate through the contents of a folder in a pst file
using VS.NET 2005 + SP1 and Outlook 2007 running on 64-bit Vista
Business.
I've added a reference to the Microsoft Office 12.0 Object Library
(shows in Solution Explorer as Microsoft.Office.Core) and
using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook;
Outlook.ApplicationClass _app = new Outlook.ApplicationClass();
The code compiles OK, but the line Outlook.ApplicationClass _app = new
"Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following
error: 80080005."
Is this also happening when you execute the code from a vbs file?

Just put this into a file olTest.vbs and post the outcome when you double
click that file:

Dim o
Set o = CreateObject("outlook.Application")
MsgBox o.name

Also check if there is a difference when Outlook ist already started.

--
SvenC
Judah Sali
2010-01-27 23:40:37 UTC
Permalink
That solves it for me too

From http://www.google.com/search?q=Retrieving+the+COM+class+factory+for+component+with+CLSID+{0006F03A-0000-0000-C000-000000000046}+failed+due+to+the+following+error:+80080005&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=

Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/
Mikel
2010-02-12 08:42:34 UTC
Permalink
How can I login as admin, I having the same error your talking about

Error al recuperar un generador de clases COM para el componente con CLSID {0006F03A-0000-0000-C000-000000000046} debido al siguiente error: 80070005.

From http://www.google.es/search?hl=es&client=firefox-a&rls=org.mozilla:es-ES:official&q=Microsoft.Office.Interop.Outlook+CLSID+solution&btnG=Buscar&meta=&aq=f&oq

Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/

Loading...