Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Exchange
2000.active.directory
2000.admin
2000.announcements
2000.app.conversion
2000.applications
2000.clients
2000.clustering
2000.connectivity
2000.development
2000.documentation
2000.general
2000.information.store
2000.interop
2000.kms
2000.misc
2000.protocols
2000.realtime.collabo.
2000.setup
2000.transport
2000.win2000
admin
application.conversion
applications
clients
clustering
connectivity
design
development
misc
mobility
setup
tools
  
 
date: Fri, 7 Mar 2008 11:34:02 -0800,    group: microsoft.public.exchange.development        back       


Accessing Exchange 2003 from C# app   
Hi all,

I need to find out my options are for writing a C# application that connects 
to an Exchange server to fetch emails. I cannot use POP3 or IMAP as they are 
both disabled and the administrators are not prepared to enable them.

The application will be running on some server without Outlook installed, so 
using the Outlook.Interop is not an option either, even though it is so easy 
to implement :(

I have looked at the option of getting the MAPI client ( 
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en 
) but it appears that this is not a supported for managed code. Is this 
correct? If not, are there any resources that explain how to do that?

So I think I am left with WebDAV, but I am not familiar at all with it. I 
found a number of samples on the web (such as 
http://blog.downtownsoftwarehouse.com/2006/10/26/using-net-and-webdav-to-access-an-exchange-server/ 
) which all look quite similar. Basically they do an initial request on:
http://<server>/exchweb/bin/auth/owaauth.dll
from where they get some authentication cookies, and then subsequent 
requests use those cookies.

However my first request always fails with a "401 - Not Authorized". Do I 
need to do an additional configuration on the Exchange server so that I can 
access it using WebDAV? I haven't found anything useful so far.

Here is the code that does the initial request to get the cookies. It always 
fails on request.GetRequestStream():
string authURI = server + "/exchweb/bin/auth/owaauth.dll";
// Create the web request body:
string body = string.Format( "destination={0}&username={1}&password={2}", 
server + path, username, password );
byte[] bytes = Encoding.UTF8.GetBytes( body );

// Create the web request:
HttpWebRequest request = (HttpWebRequest)System.Net.WebRequest.Create( 
authURI );
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.CookieContainer = new CookieContainer();
request.ContentLength = bytes.Length;

// Create the web request content stream:
using ( Stream stream = request.GetRequestStream() ) {
    stream.Write( bytes, 0, bytes.Length );
    stream.Close();
}

Are there any other options apart from those I mentioned?

many thanks.
date: Fri, 7 Mar 2008 11:34:02 -0800   author:   Kostas

Re: Accessing Exchange 2003 from C# app   
=?Utf-8?B?S29zdGFz?=  wrote in
news:1F696E77-AC8D-48AC-9057-AA5F444E3C58@microsoft.com: 
> I need to find out my options are for writing a C# application that
> connects to an Exchange server to fetch emails. 

http://support.microsoft.com/kb/813349

 Basically, you're right -- WebDAV is your best bet, if you can get it 
to work. 

> I have looked at the option of getting the MAPI client ( 
> http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-
079A-
> 43A9-BFF2-0A110307611E&displaylang=en ) but it appears that this is
> not a supported for managed code. Is this correct? If not, are there
> any resources that explain how to do that? 

 mapi33.net is a .Net wrapper, but it's unsupported and may well blow up 
unexpectedly (see numerous past postings to this group and others for 
more details).
 
> So I think I am left with WebDAV, but I am not familiar at all with
> it. I found a number of samples on the web 

 Try infinitec.de, or look for past postings from Henning Krause to this 
group, he knows all about WebDAV.

 -- dan
date: Fri, 07 Mar 2008 16:07:28 -0800   author:   Dan Mitchell

Re: Accessing Exchange 2003 from C# app   
Thanks very much Dan. I'll check them out.

Kostas
date: Mon, 10 Mar 2008 00:28:55 -0700 (PDT)   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us