Solved

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

Posted on 2004-10-20
3
601 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
3 Comments
 
LVL 5

Accepted Solution

by:
steve_bagnall earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now