Hi ,
I'm using VS 2005 and Exchange 2007. I'm trying to get the attachment which is a jpg image from an email message and save it locally to my HDD.
The code I'm using is the following.
After the wcClient.DownloadData(Str) I'm getting an exceptionCode:XmlNode.InnerText is a valid path which contains https://10.2.5.59/exchange/username/Sent%20Items/TEST.EML/Sunset.jpg FileNameNode.InnerText is the name of the file which is attached in the email message Dim MyCredentialCache As System.Net.CredentialCache Dim bytes() As Byte Dim wcClient As New System.Net.WebClient ServicePointManager.ServerCertificateValidationCallback = New _ RemoteCertificateValidationCallback(AddressOf ValidateCertificate) MyCredentialCache = New System.Net.CredentialCache MyCredentialCache.Add(New System.Uri(_XmlNode.InnerText), _ "NTLM", _ New System.Net.NetworkCredential(UserName, PassWord, Domain) _ ) ' Create the PUT HttpWebRequest object. wcClient.Credentials = MyCredentialCache Dim Str As String Str = _XmlNode.InnerText Dim _ResponseBody() As Byte = wcClient.DownloadData(Str) My.Computer.FileSystem.WriteAllBytes(AttachmentDir & "\" & FileNameNode.InnerText, _ResponseBody, False) MeMe.AttachmentPaths = Me.AttachmentPaths & "=" & AttachmentDir & "\" & FileNameNode.InnerText ' wcClient.DownloadFile(_XmlNode.InnerText, AttachmentDir & "\" & FileNameNode.InnerText) wcClient.Dispose() wcClient = Nothing Catch ex As System.Exception ErrorCode = -1 Me.SetErrorMessage(ex.Message) Throw ex End Try
The remote server returned an error: (501) Not Implemented
What is that ?????
How can I overcome with this ?
I have also tried to write wcClient.Downloadfile(url , "c:\test.jpg") but with no success.
Same exception
I have checked the Exchange 2007 and the POP3 is enabled. Should I need to configure anything else ?
What am I missing ?
I have also tried Httpwebrequest and webrequest classes. They return the same error.
Any ideas ?
Thank you


Reply With Quote