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,


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.
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.


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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countAbc challenge 9 49
mapAB Challlenge 35 88
python sqlite question 11 43
listing all functions in JavaScript 19 105
This article will show, step by step, how to integrate R code into a R Sweave document
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

757 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

22 Experts available now in Live!

Get 1:1 Help Now