views:

3117

answers:

7

I need to connect to Outlook through ASP.NET web application using user credentials. What are my options?

FYI: User logs into the web site by using Windows Authentication. I'm working with Outlook 2003.

A: 

I'm going to do something similar, and I don't see a reason it wouldn't work: write an Outlook Addin that uses object remoting to communicate with whatever other services or tools you're working on. Since it's an ASP.NET application, maybe you want to use a web service instead of object remoting.

Do you want the ASP.NET application to start Outlook if it's not already running? Is one Outlook process going to be shared by many users, or do you want to connect to user-specific Outlook processes? Do you want the ASP.NET application to act as a server that Outlook tries to connect to, or the other way around?

If the edge cases are complicated, you could try writing a Windows Service to act as an intermediary or gateway between the two e.g. a service that runs on each Outlook machine and starts Outlook on demand.

Joshua Tacoma
A: 

jtacoma: Do you want the ASP.NET application to start Outlook if it's not already running?

Whatever would be easier. If it doesn't matter that Outlook is not running then we don't need to start it.

Is one Outlook process going to be shared by many users, or do you want to connect to user-specific Outlook processes?

Need to connect to user-specific Outlook process.

Do you want the ASP.NET application to act as a server that Outlook tries to connect to, or the other way around?

The other way around. I want ASP.NET to connect to Outlook.

Also: I'm currently looking at another asp.net application and they are connecting to Outlook by using WebDAV request. I'm not sure if this is a good way to do it. Looks pretty messy to me.

dev.e.loper
Interesting... WebDav might be simpler than Object Remoting, depending what kind of information you want your ASP.NET application to get from Outlook. btw, it'd be good to add these details to the original question, rather than posting them in an answer.
Joshua Tacoma
I'm new to stackoverflow. I couldn't figure out how to add these to original question. I wanted to put it in a comment but I only have 300 char.
dev.e.loper
A: 

Does your solution require that Outlook run on the ASP.NET server? If so, you may want to research the licensing implications. I don't think MS intends Outlook to be automated in this way. I also don't think it's possible to have multiple instances of Outlook running, which could present a serious performance bottleneck problem. It would help if you could share more detail- what actions are you trying to automate through Outlook? Is an Exchange Server involved?

Dave Swersky
A: 

Outlook is actually nicely exposed through a set of COM API's...however, I'm curious as to if you need to connect to the Outlook client, or connect directly to an Exchange server.

What is the actual task you are trying to do?

For example, Once you import the outlook com DLL, and create an interop library, its fairly trivial to do most things:

outlook.Application outlookApp = new outlook.ApplicationClass();
outlook.NameSpace olNameSpace = outlookApp.GetNamespace("MAPI");
olNameSpace.Logon (Credentials); 

outlook.ContactItem contact = (outlook.ContactItem)
     outlookApp.CreateItem(OlItemType.olContactItem);

contact.FirstName = "Joe";
contact.LastName = "Smith";

contact.Save();

That snippet creates a new contact in outlook.

FlySwat
I need to be able to create calendar events and contacts. I wasn't sure how to connect to outlook. From previous projects I seen others connecting using WebDAV. Is that good/bad? Is longing on like you have above all I need to connect? Is there more complete code out there?
dev.e.loper
A: 

To me, the question doesn't make sense. Outlook isn't a server application, it has a user context. It would make more sense if you were to connect to an Exchange Server using WebDAV, MAPI, or IMAP.

dpurrington
yes thats what i meant. i want to connect to exchange server. but i was not sure which way to do it. webdav ? mapi? imap?
dev.e.loper
WebDAV is probably the best way to go. MAPI is nasty.
dpurrington
+1  A: 

Sounds like you actually want to connect to Exchange. For exchange earlier than 2007, WebDAV is the way to go. For Exchange 2007, they have webservices avaiable.

Independentsoft make a good (and cheap) .NET library for all you exchange mailbox (and calendar) needs.

Robert Wagner
A: 

Yes. I think I need to connect to exchange instead of working with Outlook COM API. Robert pointed out that WebDav might be the way to go for exchange server earlier than 2007. Are there other ways to connect to exchange server?

dev.e.loper
Yes there are other ways. As I said, you can use MAPI.
dpurrington