Solved

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

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

Suggested Solutions

Title # Comments Views Activity
WSDL Soap Error 12 281
Simple PHP - search by location postcode/zip code 8 35
XSL Grouping 7 42
Create animated movies for web page 18 85
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

860 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