Solved

C#.Net - "Access is denied" error when trying to create and send Outlook Appointment Item

Posted on 2004-10-20
3
619 Views
Last Modified: 2010-04-06
I am trying to interface with the Microsoft Outlook 11.0 Object Library within my C#.Net web application in order to programmatically create an Outlook Appointment Item and send it.  I have added a reference to the Outlook Object Library.

Here is my code:
private void Button1_Click(object sender, System.EventArgs e)
            {
                  Outlook._Application outapp = new Outlook.ApplicationClass();
                  Outlook._AppointmentItem outitem = (Outlook._AppointmentItem)outapp.CreateItem(Outlook.OlItemType.olAppointmentItem);

                  Outlook.Recipient myrecip = (Outlook.Recipient)outitem.Recipients.Add("myemailaddress");
                  
                  outitem.Start = new System.DateTime(2004,10,20,11,30,00);
                  outitem.End = outitem.Start.AddHours(2);
                  outitem.Subject = "class";
                  outitem.Location = "conference";
                  outitem.Body = "class";
                  outitem.ReminderMinutesBeforeStart = 15;
                  outitem.Save();
                  outitem.Send();
            }

I am getting an "Access is Denied"  error coming from this line:
Outlook._Application outapp = new Outlook.ApplicationClass();

I also get this semi-generic message:
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.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.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

I understand that I have not given the right access to the aspnet thread to some file, but I need to know what file it is that I need to change the security permissions of???

I have changed the permissions for the aspnet thread for the msoutl.olb file that as far as I know is the COM object that should be getting used here.

What am I doing wrong?

Thanks in advance.
0
Comment
Question by:aeromatt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
steve_bagnall earned 500 total points
ID: 12445207
Hi,

Not too sure about this myself, but if you search for this error on Google, other people seem to get "Access to <helpful pathname> Denied" instead of your simple "Access Denied".  Now this is where my knowledge is limited, but maybe you can use trace switches in your apps config file too increase the level of detail in your error messages?

What I found:

Info about TraceSwitch.TraceVerbose Property from MS...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbcontraceswitches.asp

How to use them ...
http://www.informit.com/guides/content.asp?g=dotnet&seqNum=204

Not sure if this will help, but I hope it does :)

Cheers,
Steve
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question