Outlook Application Error
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
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.UnauthorizedAccessExcept
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
Microsoft.Office.Interop
Microsoft.Office.Tools.Outlook Microsoft.Office.Interop item = (Microsoft.Office.Interop catch (COMException ex)
app = new Microsoft.Office.Interop
ns.Logon(null,null , false, true);
item.FirstName = "Tim";
item.LastName = "Taylor";
item.Email1Address = "something@hotmail.com";
item.MobileTelephoneNumber = "32165465";
}
{
Console.WriteLine(ex.ToString());
}
}

