Extract Attachment using MSXML2
Hi,
I want to extract an Attachment from Exchange Server 2003 using MSXML2 and
C#. I do get the attachment name, but when i save it to drive, it's just
binary data or junk. The attachment is an Excel document. Here's the code I
use below.
public void SaveAttachmentFile(Uri uri, FileInfo file)
{
MSXML2.XMLHTTP40 oXMLHttp = new MSXML2.XMLHTTP40();
oXMLHttp.open("GET", uri.AbsoluteUri, false, this._domain +"\\"+
this._userName, this._password);
oXMLHttp.setRequestHeader("Depth", "1");
oXMLHttp.setRequestHeader("Translate","f");
oXMLHttp.send(null);
FileStream fs= new
FileStream(file.FullName,FileMode.Create,FileAccess.Write,FileShare.Read);
using (StreamWriter sWriter = new StreamWriter(fs,Encoding.UTF8))
{
sWriter.WriteLine("{0}",oXMLHttp.responseText);
}
}
PS: I am obliged to use MSXML2 - Company Politics :(
Regards
walter
date: Thu, 11 May 2006 07:36:02 -0700
author: walterd