Source Code to connect Outlook from ASP.Net Web Application

Posted on 2004-04-28
Last Modified: 2007-12-19

I am looking for a source code to read contacts in Outlook from a Web application written in C#.

I have no problem to write a program in C# Windows form that access outlook.

But when I do the same programming code in a web application, the web application doesn't work for authorizations reasons.

Can you help me to solve this problem?

Thank you very much,

Question by:olivierverdin

Expert Comment

ID: 10943879
Is your website using authentication or anonymous access? If anonymous then your code is trying to establish a MAPI session using the account assigned (IUSR_*).

One way to fix this is change the anonymous user to a new account. Log into this new account and set up a default email profile.

Expert Comment

ID: 10943972
After reading your question the first thing that came to mind was a program I wrote in C++ a few years back that I ended up using tokens to elevate my user levels.  With that said, I was curious how I'd do that in .Net without having to use the Interop.  Here is a pretty sweet link... I think you may find what you need in this page.

Best regards,

Expert Comment

ID: 10945814
What you need to do is to enable impersonation in the web config. I had a similar situation and I created an account with the proper permissions in the domain, and then I used forms based security because once they passed the security they have the proviledges of the impersonated user.

Create your user and then add this line to your web.config

<identity impersonate="true"
          password="password" />

Remember that once your users are on your application they will execute their code with the user credentials. If you want to force each user to use their own credentials then only use this line:

<identity impersonate="true" />

I had to use a user account because the things I wanted my users to do required elevated privileges that I did not want to give them, so I just had them impersonate as a user with those privileges.

Hope this helps,

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.


Expert Comment

ID: 10945825
Oh, one more thing, if you use impersonation you need to turn on one of the authentication methods in IIS, either Basic Challenge Response, or Integrated Windows Security.

Author Comment

ID: 10946903
I need to force each user to use their own credentials so I will use <identity impersonate = "true" />

but how do you turn on one of the authentication methods in IIS?  I did'nt find these options in IIS.

Thanks for your help,


Accepted Solution

jangeador earned 500 total points
ID: 10950478
In the IIS management right click on your site, then go to properties, then go to the "Directory Security" tab, and then under the "Anonymous Access and Authentication Control" you can find the options mentioned above.

Just remember, by default all processes run under the LocalServer\ASPNET account. you need to ensure that all your users belong to a security group which has access to all the resources on your site, such as sql server or any other resource.

Here is a good article that perhaps you should check out.

Author Comment

ID: 10952820
Ok, I will read this article and try to understand.

I changed the authorizations of IIS.  Now the application is not crashing but it is waiting for the response of the web server and it stays like this forever!

Any idea of the problem?



Expert Comment

ID: 10953556
I will try to put a user information in the impersonation line just to test it. I am really not sure what information is waiting for. have you tried debugging to see which line is getting stuck on?

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 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