priyankaa 0 Newbie Poster

i am reading mail from exchange and downloading the mail attachment.

i am using webclient.downloadfile() functino to download the attchment .the code is working fine through http:// url in my machine.

but its not working in client machine,because the url contains https://.

below is the code:

MSXML2.XMLHTTP40 ObjXmlHttp = new MSXML2.XMLHTTP40();
MSXML2.DOMDocument40 ObjXmlDomDoc = new MSXML2.DOMDocument40();

ObjXmlHttp.open("X-MS-ENUMATTS", strEMLUrl, false, strUsername, strPassword);
ObjXmlHttp.setRequestHeader("Depth", "1");
ObjXmlHttp.setRequestHeader("Content-type", "xml");

ObjXmlHttp.send("");

XmlDocument ObjXmlDocAttachments = new XmlDocument();

ObjXmlDocAttachments.LoadXml(ObjXmlHttp.responseText);
XmlNodeList ObjXmlNodeLstAttachment = ObjXmlDocAttachments.GetElementsByTagName("a:response");

string[] arrAttachFiles = new string[ObjXmlNodeLstAttachment.Count];

 int i=0;
 foreach (XmlNode node in ObjXmlNodeLstAttachment)
 {
         XmlElement ObjXmlElementAttachment = (XmlElement)node;
         string strAttachmentFileUrl = ObjXmlElementAttachment.GetElementsByTagName("a:href")[0].InnerText;

         System.Net.WebClient ObjWeb = new WebClient();
         ObjWeb.Credentials = new NetworkCredential(strUsername,strPassword);
          ObjWeb.DownloadFile(strAttachmentFileUrl, strNewFileName);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.