Retrieving .EML files using WebDAV

Retrieving .EML files using WebDAV

Post by TmdlbF » Thu, 20 Apr 2006 01:25:01

Hi all,

I am trying to use WebDAV to allow users to select emails from their Inbox
to be saved to a location on disk, including the email's attachments (if any).

To do this I generate a list of the emails via a WebDAV SEARCH query
(returns sender, subject, date and href), and then allow the users to select
which emails should be moved, then finally click a button to move.

I would like to grab the emails in EML format, with the attachments MIME
encoded within the file, but am not sure how to do this with WebDAV - I guess
it would be fairly straight forward seeing as I have the href.

Could someone explain how to do this, or let me know if there is a better
way to do this.

Many thanks,

Retrieving .EML files using WebDAV

Post by Henning Kr » Thu, 20 Apr 2006 02:19:55


just do a GET on the href and add the header "Tranlate: f" to the request.

Henning Krause


Retrieving .EML files using WebDAV

Post by TmdlbF » Sun, 23 Apr 2006 00:06:01

Hi, I have tried to do this with the following function, but it seems to
fail, with the responseStream.Length = "<error: an exception of type:
{System.NotSupportedException} occured>". Am I doing something silly in my
------- code snippet -------
private Stream GetWebDAVResource(string resourceUri)
HttpWebRequest request;
WebResponse response = null;
Stream responseStream = null;
CookieCollection cookies = null;

//if SSL is enabled on the exchange server, make
//sure all ssl certificates are accepted
if( usingSSL )
System.Net.ServicePointManager.CertificatePolicy = new SSLHandler();

//Create the HttpWebRequest object.
request = (System.Net.HttpWebRequest)HttpWebRequest.Create(resourceUri);

////Set common properties
request.Timeout = 600000;
request.ContentType = "text/xml";

CredentialCache credentials = new CredentialCache();
credentials.Add(new Uri(uriToGet), "NTLM", new NetworkCredential(username,
password, domain));
request.Credentials = credentials;

//Specify the method.
request.Method = "GET";

//Set the Translate header.

//Get the response from the server.
response = (HttpWebResponse)request.GetResponse();

//Get XML response stream
responseStream = response.GetResponseStream();

// Clean up.
catch(Exception ex)


------- end snippet -------

Many thanks,

Nigel W

Retrieving .EML files using WebDAV

Post by Thomas Del » Wed, 26 Apr 2006 03:00:42

You code snippet looks basically that same as some working code that we
have, the only difference being that our code does not have:

////Set common properties
request.Timeout = 600000;
request.ContentType = "text/xml";

Also, we are using a BinaryReader to process the ResponseStream that we
get back.

Wish I could be more help.

Tom Delany

Retrieving .EML files using WebDAV

Post by TmdlbF » Thu, 27 Apr 2006 15:57:01

got it working now - Many thanks ;-)