[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Outlook 2007 automation with VS.NET 2005

Mark Rae

5/1/2007 4:53:00 PM

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/aa4... 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

10 Answers

Dannel Albert

5/4/2007 6:39:00 PM

0

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/aa4... 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

5/4/2007 6:57:00 PM

0

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/aa4... 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

5/5/2007 5:36:00 AM

0

On Fri, 04 May 2007, Dannel Albert wrote:

>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...) 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

5/17/2007 5:35:00 AM

0

Please read the following article:

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

Moiz
MCSD

Moiz

5/17/2007 5:36:00 AM

0

Please read the following article:

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

Moiz
MCSD

Dhanji

5/17/2007 5:45:00 AM

0

seems helpful ....

Nate Finch

5/21/2007 3:05:00 PM

0

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


On May 1, 12:53 pm, "Mark Rae" <m...@markNOSPAMrae.net> wrote:
> 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... 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


Nate Finch

5/21/2007 3:18:00 PM

0

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.

On May 17, 1:35 am, Moiz wrote:
> Please read the following article:
>
> http://msdn2.microsoft.com/en-us/librar...(office.11).aspx
>
> Moiz
> MCSD


SvenC

5/21/2007 3:45:00 PM

0

Hi Mark,

Mark Rae wrote:
> 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
> 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."

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

Mark Rae

6/2/2007 4:21:00 PM

0

"Nate Finch" <nate.finch@gmail.com> wrote in message
news:1179759927.841784.126600@y18g2000prd.googlegroups.com...

>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...?

> But you started Outlook just by hitting the shortcut in the start menu?

Correct.

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

> Hope this helps!

Thanks very much.


--
http://www.m...