Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Source Code to connect Outlook from ASP.Net Web Application

Posted on 2004-04-28
Medium Priority
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,

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


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 1500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

564 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