Outlook Application Error

Im making an application that writes contacts into the MS Outlook database. Im using

Visual Studio 2005
Windows XP service pack 2
MS Outlook 2003
Im writing my code on a virtual machine (Windows XP service pack 2).

Im using theMicrosoft Outlook 11.0 Object Librarywhich ships with Outlook 2003.I have added it as a reference in my project.This method WriteItems() is a part of anASP.NET file. I have shown the code below. After writing the code, it compiles successfully. But when I run this, I get the error :

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to theASP.NET request identity.ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

public void WriteItems()
{
try
{
Microsoft.Office.Interop

.Outlook.Application app = null;
Microsoft.Office.Interop.Outlook.ContactItem item = null;

Microsoft.Office.Tools.Outlook.Application
app = new Microsoft.Office.Interop.Outlook.Application();

Microsoft.Office.Interop.Outlook.NameSpace ns = app.GetNamespace("MAPI");
ns.Logon(null,null , false, true);

item = (Microsoft.Office.Interop.Outlook.ContactItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olContactItem );
item.FirstName = "Tim";
item.LastName = "Taylor";
item.Email1Address = "something@hotmail.com";
item.MobileTelephoneNumber = "32165465";
}

catch (COMException ex)
{
Console.WriteLine(ex.ToString());
}
}

[3185 byte] By [Ankini] at [2008-2-15]
# 1

Hi,

If you are using IIS 6 change the username on the application pool, grant access to this user.

Cheers

SalvaPatuel at 2007-9-10 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 2
Hi

I added references of Outlook into my application for opening email client using my ASP.NET project,, its working fine in DEBUG mode,,,

but when i install this application on to my WINDOWS 2000 TERMINAL SERVER , this error is shown

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.

How should i solve this problem,,,

I am using ASP.NET 2.0,,,

it is perfectly working in DEBUG mode......

only when installed in SERVER its showing the above error

Thanks & regards

winnie cherian

winniecherian at 2007-9-10 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 3

i am also facing the same problem

my application is running fine when i am running the application.

but when i am going for throught virtual directory created in IIS it is throughing the same error as

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.

if any one of you got solution please post it.

Thanks and Regards

Gnana Prakash Bodireddy.

Gnana at 2007-9-10 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 4
It seems that we have encountered the same problem. Do you have solved this problem? It will be very helpful to me. Many thanks.
CCHuang at 2007-9-10 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...