Solved

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

Posted on 2004-10-20
3
612 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

739 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